Java Code Examples for org.eclipse.swt.graphics.Rectangle#intersects()
The following examples show how to use
org.eclipse.swt.graphics.Rectangle#intersects() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenameRefactoringPopup.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void updateVisibility() { if (popup != null && !popup.isDisposed() && delayJobFinished) { boolean visible = false; if (renameLinkedMode.isCaretInLinkedPosition()) { StyledText textWidget = editor.getInternalSourceViewer().getTextWidget(); Rectangle eArea = Geometry.toDisplay(textWidget, textWidget.getClientArea()); Rectangle pBounds = popup.getBounds(); pBounds.x -= GAP; pBounds.y -= GAP; pBounds.width += 2 * GAP; pBounds.height += 2 * GAP; if (eArea.intersects(pBounds)) { visible = true; } } if (visible && !popup.isVisible()) { ISourceViewer viewer = editor.getInternalSourceViewer(); if (viewer instanceof IWidgetTokenOwnerExtension) { IWidgetTokenOwnerExtension widgetTokenOwnerExtension = (IWidgetTokenOwnerExtension) viewer; widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY); } } else if (!visible && popup.isVisible()) { releaseWidgetToken(); } popup.setVisible(visible); } }
Example 2
Source File: RenameInformationPopup.java From typescript.java with MIT License | 5 votes |
private void updateVisibility() { if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) { boolean visible= false; //TODO: Check for visibility of linked position, not whether popup is outside of editor? if (fRenameLinkedMode.isCaretInLinkedPosition()) { StyledText textWidget= fEditor.getViewer().getTextWidget(); Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea()); Rectangle pBounds= fPopup.getBounds(); pBounds.x-= GAP; pBounds.y-= GAP; pBounds.width+= 2 * GAP; pBounds.height+= 2 * GAP; if (eArea.intersects(pBounds)) { visible= true; } } if (visible && ! fPopup.isVisible()) { ISourceViewer viewer= fEditor.getViewer(); if (viewer instanceof IWidgetTokenOwnerExtension) { IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer; visible= widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY); } } else if (! visible && fPopup.isVisible()) { releaseWidgetToken(); } fPopup.setVisible(visible); } }
Example 3
Source File: BonitaContentProposalAdapter.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void adjustBounds() { final Rectangle parentBounds = getParentShell().getBounds(); Rectangle proposedBounds; // Try placing the info popup to the right Rectangle rightProposedBounds = new Rectangle(parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING, parentBounds.y + PopupDialog.POPUP_VERTICALSPACING, parentBounds.width, parentBounds.height); rightProposedBounds = getConstrainedShellBounds(rightProposedBounds); // If it won't fit on the right, try the left if (rightProposedBounds.intersects(parentBounds)) { Rectangle leftProposedBounds = new Rectangle(parentBounds.x - parentBounds.width - POPUP_HORIZONTALSPACING - 1, parentBounds.y, parentBounds.width, parentBounds.height); leftProposedBounds = getConstrainedShellBounds(leftProposedBounds); // If it won't fit on the left, choose the proposed bounds // that fits the best if (leftProposedBounds.intersects(parentBounds)) { if (rightProposedBounds.x - parentBounds.x >= parentBounds.x - leftProposedBounds.x) { rightProposedBounds.x = parentBounds.x + parentBounds.width + PopupDialog.POPUP_HORIZONTALSPACING; proposedBounds = rightProposedBounds; } else { leftProposedBounds.width = parentBounds.x - POPUP_HORIZONTALSPACING - leftProposedBounds.x; proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the left proposedBounds = leftProposedBounds; } } else { // use the proposed bounds on the right proposedBounds = rightProposedBounds; } getShell().setBounds(proposedBounds); }
Example 4
Source File: SelectionModel.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private void addSelectionIntoList(Rectangle selection) { selectionsLock.writeLock().lock(); try { ArrayList<Rectangle> itemsToRemove = null; for (Rectangle r : selections) { if (selection.intersects(r)) { if (r.equals(selection)) { break; } Rectangle intersection = selection.intersection(r); if (intersection.equals(r)) { // r is a subset of intersection if (itemsToRemove == null) itemsToRemove = new ArrayList<Rectangle>(); itemsToRemove.add(r); } else if (intersection.equals(selection)) { // selection is a subset of r break; } } } if (itemsToRemove != null) { selections.removeAll(itemsToRemove); } selections.add(selection); } finally { selectionsLock.writeLock().unlock(); } }
Example 5
Source File: SelectionModel.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void addSelectionIntoList(Rectangle selection) { selectionsLock.writeLock().lock(); try { ArrayList<Rectangle> itemsToRemove = null; for (Rectangle r : selections) { if (selection.intersects(r)) { if (r.equals(selection)) { break; } Rectangle intersection = selection.intersection(r); if (intersection.equals(r)) { // r is a subset of intersection if (itemsToRemove == null) itemsToRemove = new ArrayList<Rectangle>(); itemsToRemove.add(r); } else if (intersection.equals(selection)) { // selection is a subset of r break; } } } if (itemsToRemove != null) { selections.removeAll(itemsToRemove); } selections.add(selection); } finally { selectionsLock.writeLock().unlock(); } }
Example 6
Source File: LineBackgroundPainter.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Draws the current line highlight (over top using theme colors and alpha). If the line highlight is fully opaque, * then this method will not do anything and we'll fall back to using the mechanism eclipse does in * CursorLinePainter with a little modification. */ public void paintControl(PaintEvent e) { // if highlight current line is disabled, don't draw! if (!fEnabled) { return; } // If there's no alpha value for the line highlight, then we need to force the bg color of the whole line // to the rgb value! RGBa lineHighlight = getCurrentTheme().getLineHighlight(); if (lineHighlight.isFullyOpaque()) { return; } Rectangle rect = new Rectangle(e.x, e.y, e.width, e.height); Rectangle lineRect = getLineRectangle(getCurrentLinePosition()); if (lineRect == null || !lineRect.intersects(rect)) { return; } int previousAlpha = e.gc.getAlpha(); Color previousBG = e.gc.getBackground(); e.gc.setAlpha(lineHighlight.getAlpha()); e.gc.setBackground(getColorManager().getColor(lineHighlight.toRGB())); // Only paint the part of lineRect that is contained in rect! e.gc.fillRectangle(lineRect.intersection(rect)); // BUGFIX: need to set alpha and background color back to what they were before or it breaks // the painting of pair matching! e.gc.setAlpha(previousAlpha); e.gc.setBackground(previousBG); }
Example 7
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void updateVisibility() { if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) { boolean visible= false; //TODO: Check for visibility of linked position, not whether popup is outside of editor? if (fRenameLinkedMode.isCaretInLinkedPosition()) { StyledText textWidget= fEditor.getViewer().getTextWidget(); Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea()); Rectangle pBounds= fPopup.getBounds(); pBounds.x-= GAP; pBounds.y-= GAP; pBounds.width+= 2 * GAP; pBounds.height+= 2 * GAP; if (eArea.intersects(pBounds)) { visible= true; } } if (visible && ! fPopup.isVisible()) { ISourceViewer viewer= fEditor.getViewer(); if (viewer instanceof IWidgetTokenOwnerExtension) { IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer; visible= widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY); } } else if (! visible && fPopup.isVisible()) { releaseWidgetToken(); } fPopup.setVisible(visible); } }
Example 8
Source File: ViewLattice.java From arx with Apache License 2.0 | 4 votes |
/** * Draws a node. * * @param g */ private void drawNodes(final GC g) { // Prepare Rectangle bounds = new Rectangle(0, 0, (int)nodeWidth, (int)nodeHeight); Transform transform = new Transform(g.getDevice()); // Set style g.setLineWidth(STROKE_WIDTH_NODE); g.setFont(font); // Draw nodes for (List<ARXNode> level : lattice) { for (ARXNode node : level) { // Obtain coordinates double[] center = (double[]) node.getAttributes().get(ATTRIBUTE_CENTER); bounds.x = (int)(center[0] - nodeWidth / 2d); bounds.y = (int)(center[1] - nodeHeight / 2d); // Clipping if (bounds.intersects(new Rectangle(0, 0, screen.x, screen.y))) { // Retrieve/compute text rendering data SerializablePath path = (SerializablePath) node.getAttributes().get(ATTRIBUTE_PATH); Point extent = (Point) node.getAttributes().get(ATTRIBUTE_EXTENT); if (path == null || path.getPath() == null) { String text = (String) node.getAttributes().get(ATTRIBUTE_LABEL); path = new SerializablePath(new Path(canvas.getDisplay())); path.getPath().addString(text, 0, 0, font); node.getAttributes().put(ATTRIBUTE_PATH, path); extent = g.textExtent(text); node.getAttributes().put(ATTRIBUTE_EXTENT, extent); } // Degrade if too far away if (bounds.width <= 4) { g.setBackground(getInnerColor(node)); g.setAntialias(SWT.OFF); g.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height); // Draw real node } else { // Fill background g.setBackground(getInnerColor(node)); g.setAntialias(SWT.OFF); if (node != getSelectedNode()) { g.fillOval(bounds.x, bounds.y, bounds.width, bounds.height); } else { g.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height); } // Draw line g.setLineWidth(getOuterStrokeWidth(node, bounds.width)); g.setForeground(getOuterColor(node)); g.setAntialias(SWT.ON); if (node != getSelectedNode()) { g.drawOval(bounds.x, bounds.y, bounds.width, bounds.height); } else { g.drawRectangle(bounds.x, bounds.y, bounds.width, bounds.height); } // Draw text if (bounds.width >= 20) { // Enable anti-aliasing g.setTextAntialias(SWT.ON); // Compute position and factor float factor1 = (bounds.width * 0.7f) / (float)extent.x; float factor2 = (bounds.height * 0.7f) / (float)extent.y; float factor = Math.min(factor1, factor2); int positionX = bounds.x + (int)(((float)bounds.width - (float)extent.x * factor) / 2f); int positionY = bounds.y + (int)(((float)bounds.height - (float)extent.y * factor) / 2f); // Initialize transformation transform.identity(); transform.translate(positionX, positionY); transform.scale(factor, factor); g.setTransform(transform); // Draw and reset g.setBackground(COLOR_BLACK); g.fillPath(path.getPath()); g.setTransform(null); g.setTextAntialias(SWT.OFF); } } } } } // Clean up transform.dispose(); }
Example 9
Source File: CTreeColumn.java From nebula with Eclipse Public License 2.0 | 4 votes |
public boolean isVisible() { Rectangle r = ctree.getClientArea(); r.x += ctree.getScrollPosition().x; return r.intersects(getBounds()); }
Example 10
Source File: TableCellEditorListener.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * http://www.eclipse.org/swt/snippets/ */ @Override public void handleEvent(Event event) { final TableEditor editor = new TableEditor(table); editor.horizontalAlignment = SWT.LEFT; editor.grabHorizontal = true; Rectangle clientArea = table.getClientArea(); if (table.getSelection().length != 1) { return; } Rectangle bounds = table.getSelection()[0].getBounds(); Point pt = new Point(bounds.x, bounds.y); int index = table.getTopIndex(); while (index < table.getItemCount()) { boolean visible = false; final SimpleTableItem item = (SimpleTableItem) table.getItem(index); for (int i = 0; i < table.getColumnCount(); i++) { Rectangle rect = item.getBounds(i); if (rect.contains(pt)) { final Text text = new Text(table, SWT.NONE); Listener textListener = new TextListener(item, text); text.addListener(SWT.FocusOut, textListener); text.addListener(SWT.Traverse, textListener); text.addListener(SWT.FocusOut, wizard); editor.setEditor(text, item, i); text.setText(item.getText(i)); text.selectAll(); text.setFocus(); return; } if (!visible && rect.intersects(clientArea)) { visible = true; } } if (!visible) { return; } index++; } }
Example 11
Source File: SelectionModel.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public void removeSelection(Rectangle removedSelection) { List<Rectangle> removedItems = new LinkedList<Rectangle>(); List<Rectangle> addedItems = new LinkedList<Rectangle>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { if (r.intersects(removedSelection)) { Rectangle intersection = removedSelection.intersection(r); removedItems.add(r); Rectangle topSelection = getTopSelection(intersection, r); if (topSelection != null) { addedItems.add(topSelection); } Rectangle rightSelection = getRightSelection(intersection, r); if (rightSelection != null) addedItems.add(rightSelection); Rectangle leftSelection = getLeftSelection(intersection, r); if (leftSelection != null) addedItems.add(leftSelection); Rectangle bottomSelection = getBottomSelection(intersection, r); if (bottomSelection != null) addedItems.add(bottomSelection); } } } finally { selectionsLock.readLock().unlock(); } if (removedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.removeAll(removedItems); } finally { selectionsLock.writeLock().unlock(); } removedItems.clear(); } if (addedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.addAll(addedItems); } finally { selectionsLock.writeLock().unlock(); } addedItems.clear(); } }
Example 12
Source File: SelectionModel.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public void removeSelection(Rectangle removedSelection) { List<Rectangle> removedItems = new LinkedList<Rectangle>(); List<Rectangle> addedItems = new LinkedList<Rectangle>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { if (r.intersects(removedSelection)) { Rectangle intersection = removedSelection.intersection(r); removedItems.add(r); Rectangle topSelection = getTopSelection(intersection, r); if (topSelection != null) { addedItems.add(topSelection); } Rectangle rightSelection = getRightSelection(intersection, r); if (rightSelection != null) addedItems.add(rightSelection); Rectangle leftSelection = getLeftSelection(intersection, r); if (leftSelection != null) addedItems.add(leftSelection); Rectangle bottomSelection = getBottomSelection(intersection, r); if (bottomSelection != null) addedItems.add(bottomSelection); } } } finally { selectionsLock.readLock().unlock(); } if (removedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.removeAll(removedItems); } finally { selectionsLock.writeLock().unlock(); } removedItems.clear(); } if (addedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.addAll(addedItems); } finally { selectionsLock.writeLock().unlock(); } addedItems.clear(); } }
Example 13
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20_Wireframe(Composite3D c3d) { if (!visible) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GL11.glPushMatrix(); GL11.glMultMatrixf(matrix); if (c3d.isShowingLogo()) { if (filesWithLogo1.contains(shortName)) drawStudLogo1_GL20(); else if (filesWithLogo2.contains(shortName)) drawStudLogo2_GL20(); } GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_Wireframe(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_Wireframe(c3d); if (GData.accumClip > 0) GData.accumClip = 0; } GL11.glPopMatrix(); } GData.globalNegativeDeterminant = tempNegativeDeterminant; } }
Example 14
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20_CoplanarityHeatmap(Composite3D c3d) { if (!visible) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GL11.glPushMatrix(); GL11.glMultMatrixf(matrix); if (c3d.isShowingLogo()) { if (filesWithLogo1.contains(shortName)) drawStudLogo1_GL20(); else if (filesWithLogo2.contains(shortName)) drawStudLogo2_GL20(); } GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_CoplanarityHeatmap(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_CoplanarityHeatmap(c3d); if (GData.accumClip > 0) GData.accumClip = 0; } GL11.glPopMatrix(); } GData.globalNegativeDeterminant = tempNegativeDeterminant; } }
Example 15
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20_BFC_Textured(Composite3D c3d) { boolean tNext = GData.globalFoundTEXMAPNEXT; GData.globalFoundTEXMAPNEXT = false; if (!visible || !GData.globalDrawObjects) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); byte tempWinding = GData.localWinding; boolean tempInvertNext = GData.globalInvertNext; boolean tempInvertNextFound = GData.globalInvertNextFound; boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalInvertNextFound = false; GData.localWinding = BFC.NOCERTIFY; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GData.globalFoundTEXMAPStack.push(false); GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_BFC_Textured(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) { data2draw.drawGL20_BFC_Textured(c3d); } if (GData.accumClip > 0) GData.accumClip = 0; } if (GData.globalFoundTEXMAPStack.peek()) { GData.globalFoundTEXMAPStack.pop(); GData.globalTextureStack.pop(); GData.globalFoundTEXMAPStack.push(false); GData.globalDrawObjects = true; } GData.globalFoundTEXMAPStack.pop(); } GData.localWinding = tempWinding; if (tempInvertNextFound) GData.globalInvertNext = !tempInvertNext; GData.globalNegativeDeterminant = tempNegativeDeterminant; } if (tNext) { GData.globalFoundTEXMAPStack.pop(); GData.globalTextureStack.pop(); GData.globalFoundTEXMAPStack.push(false); GData.globalFoundTEXMAPNEXT = false; } }
Example 16
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20_BFCuncertified(Composite3D c3d) { if (!visible) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); byte tempWinding = GData.localWinding; boolean tempInvertNext = GData.globalInvertNext; boolean tempInvertNextFound = GData.globalInvertNextFound; boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GL11.glPushMatrix(); GL11.glMultMatrixf(matrix); if (c3d.isShowingLogo()) { if (filesWithLogo1.contains(shortName)) drawStudLogo1_GL20(); else if (filesWithLogo2.contains(shortName)) drawStudLogo2_GL20(); } GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_BFCuncertified(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_BFCuncertified(c3d); if (GData.accumClip > 0) GData.accumClip = 0; } GL11.glPopMatrix(); } GData.localWinding = tempWinding; if (tempInvertNextFound) GData.globalInvertNext = !tempInvertNext; GData.globalNegativeDeterminant = tempNegativeDeterminant; } }
Example 17
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20_RandomColours(Composite3D c3d) { if (!visible) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GL11.glPushMatrix(); GL11.glMultMatrixf(matrix); if (c3d.isShowingLogo()) { if (filesWithLogo1.contains(shortName)) drawStudLogo1_GL20(); else if (filesWithLogo2.contains(shortName)) drawStudLogo2_GL20(); } GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_RandomColours(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20_RandomColours(c3d); if (GData.accumClip > 0) GData.accumClip = 0; } GL11.glPopMatrix(); } GData.globalNegativeDeterminant = tempNegativeDeterminant; } }
Example 18
Source File: GData1.java From ldparteditor with MIT License | 4 votes |
@Override public void drawGL20(Composite3D c3d) { if (!visible) return; if (matrix != null) { final Rectangle bounds = c3d.getClientArea(); final PerspectiveCalculator PC = c3d.getPerspectiveCalculator(); Vector4f bbmin = new Vector4f(); Vector4f bbmax = new Vector4f(); Vector4f c1 = new Vector4f(boundingBoxMin); Vector4f c2 = new Vector4f(boundingBoxMin); Vector4f c3 = new Vector4f(boundingBoxMin); Vector4f c4 = new Vector4f(boundingBoxMin); Vector4f c5 = new Vector4f(boundingBoxMax); Vector4f c6 = new Vector4f(boundingBoxMax); Vector4f c7 = new Vector4f(boundingBoxMax); Vector4f c8 = new Vector4f(boundingBoxMax); c2.x = boundingBoxMax.x; c3.y = boundingBoxMax.y; c4.z = boundingBoxMax.z; c6.x = boundingBoxMin.x; c7.y = boundingBoxMin.y; c8.z = boundingBoxMin.z; c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z)); c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z)); c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z)); c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z)); c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z)); c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z)); c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z)); c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z)); bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x))))))); bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x))))))); bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y))))))); bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y))))))); Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y)); boolean tempNegativeDeterminant = GData.globalNegativeDeterminant; GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant; if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0) || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) { GL11.glPushMatrix(); GL11.glMultMatrixf(matrix); if (c3d.isShowingLogo()) { if (filesWithLogo1.contains(shortName)) drawStudLogo1_GL20(); else if (filesWithLogo2.contains(shortName)) drawStudLogo2_GL20(); } GData data2draw = myGData; if (GData.accumClip > 0) { GData.accumClip++; while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20(c3d); GData.accumClip--; } else { while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get()) data2draw.drawGL20(c3d); if (GData.accumClip > 0) GData.accumClip = 0; } GL11.glPopMatrix(); } GData.globalNegativeDeterminant = tempNegativeDeterminant; } }
Example 19
Source File: TimeGraphRender.java From tracecompass with Eclipse Public License 2.0 | 3 votes |
/** * Can the items be merged? (note, right needs to have x >= left's x) * * @param left * the left element * @param right * the right element * @return true if the items can be merged */ public static boolean areMergeable(DeferredItem left, DeferredItem right) { Rectangle rightBounds = right.getBounds(); Rectangle largerBounds = new Rectangle(rightBounds.x - 1, rightBounds.y, rightBounds.width + 1, rightBounds.height); return Objects.equals(left.getBackgroundColor(), right.getBackgroundColor()) && Objects.equals(left.getBorderColor(), right.getBorderColor()) && largerBounds.intersects(left.getBounds()) && largerBounds.height == right.getBounds().height; }