Java Code Examples for java.awt.Graphics.hitClip()
The following are Jave code examples for showing how to use
hitClip() of the
java.awt.Graphics
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Tarski File: mxEdgeHandler.java View Source Code | 7 votes |
/** * */ public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); Point last = state.getAbsolutePoint(0).getPoint(); for (int i = 1; i < state.getAbsolutePointCount(); i++) { Point current = state.getAbsolutePoint(i).getPoint(); Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y); Rectangle bounds = g2.getStroke().createStrokedShape(line).getBounds(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { g2.draw(line); } last = current; } g2.setStroke(stroke); super.paint(g); }
Example 2
Project: TrabalhoFinalEDA2 File: mxVertexHandler.java View Source Code | 6 votes |
/** * */ public void paint(Graphics g) { Rectangle bounds = getState().getRectangle(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setStroke(stroke); } super.paint(g); }
Example 3
Project: TrabalhoFinalEDA2 File: mxCellHandler.java View Source Code | 6 votes |
/** * Paints the visible handles of this handler. */ public void paint(Graphics g) { if (handles != null && isHandlesVisible()) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i) && g.hitClip(handles[i].x, handles[i].y, handles[i].width, handles[i].height)) { g.setColor(getHandleFillColor(i)); g.fillRect(handles[i].x, handles[i].y, handles[i].width, handles[i].height); g.setColor(getHandleBorderColor(i)); g.drawRect(handles[i].x, handles[i].y, handles[i].width - 1, handles[i].height - 1); } } } }
Example 4
Project: Tarski File: mxVertexHandler.java View Source Code | 6 votes |
/** * */ public void paint(Graphics g) { Rectangle bounds = getState().getRectangle(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setStroke(stroke); } super.paint(g); }
Example 5
Project: incubator-netbeans File: SheetTable.java View Source Code | 5 votes |
/** Paint the outside margin where the spinners for expandable * sets are. This should be derived from the standard control * color. This method will overpaint the grid lines in this * area. */ private void paintMargin(Graphics g) { //Don't paint the margin for sorted modes //fill the outer column with the set renderer color, per UI spec g.setColor(PropUtils.getSetRendererColor()); int w = PropUtils.getMarginWidth(); int h = getHeight(); if (g.hitClip(0, 0, w, h)) { g.fillRect(0, 0, w, h); } }
Example 6
Project: incubator-netbeans File: RadioInplaceEditor.java View Source Code | 5 votes |
public void paint(Graphics g) { if (isShowing()) { super.paint(g); } else { getLayout().layoutContainer(this); Component[] c = getComponents(); Color col = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); for (int i = 0; i < c.length; i++) { Rectangle r = c[i].getBounds(); if (g.hitClip(r.x, r.y, r.width, r.height)) { Graphics g2 = g.create(r.x, r.y, r.width, r.height); try { c[i].paint(g2); } finally { g2.dispose(); } } } if (getBorder() != null) { super.paintBorder(g); } } finally { g.setColor(col); } } }
Example 7
Project: incubator-netbeans File: MarginViewportUI.java View Source Code | 5 votes |
/** Overridden to draw "no properties" if necessary */ public void paint(Graphics g, JComponent c) { Component view = ((JViewport) c).getView(); if (view != null) { lastKnownSize = view.getSize(); } if (stringWidth == -1) { calcStringSizes(c.getFont(), g); } //Update will have set paintNoProps to the correct value if (shouldPaintEmptyMessage()) { //We need to paint centered "<No Properties>" text g.setFont(c.getFont()); g.setColor(c.getForeground()); Rectangle r = getEmptyMessageBounds(); //See if we really need to do any painting if (g.hitClip(r.x, r.y, r.width, r.height)) { //Paint the string g.drawString(emptyString, r.x, r.y + ascent); } } }
Example 8
Project: incubator-netbeans File: AbstractViewTabDisplayerUI.java View Source Code | 5 votes |
@Override public void paint(Graphics g, JComponent c) { ColorUtil.setupAntialiasing(g); TabData tabData; int x, y, width, height; String text; paintDisplayerBackground( g, c ); for (int i = 0; i < dataModel.size(); i++) { // gather data tabData = dataModel.getTab(i); x = layoutModel.getX(i); y = layoutModel.getY(i); width = layoutModel.getW(i); height = layoutModel.getH(i); text = tabData.getText(); // perform paint if (g.hitClip(x, y, width, height)) { paintTabBackground(g, i, x, y, width, height); paintTabContent(g, i, text, x, y, width, height); paintTabBorder(g, i, x, y, width, height); } } }
Example 9
Project: TrabalhoFinalEDA2 File: mxEdgeHandler.java View Source Code | 5 votes |
/** * */ public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = g2.getStroke(); g2.setStroke(getSelectionStroke()); g.setColor(getSelectionColor()); Point last = state.getAbsolutePoint(0).getPoint(); for (int i = 1; i < state.getAbsolutePointCount(); i++) { Point current = state.getAbsolutePoint(i).getPoint(); Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y); Rectangle bounds = g2.getStroke().createStrokedShape(line) .getBounds(); if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { g2.draw(line); } last = current; } g2.setStroke(stroke); super.paint(g); }
Example 10
Project: Tarski File: mxCellHandler.java View Source Code | 5 votes |
/** * Paints the visible handles of this handler. */ public void paint(Graphics g) { if (handles != null && isHandlesVisible()) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i) && g.hitClip(handles[i].x, handles[i].y, handles[i].width, handles[i].height)) { g.setColor(getHandleFillColor(i)); g.fillRect(handles[i].x, handles[i].y, handles[i].width, handles[i].height); g.setColor(getHandleBorderColor(i)); g.drawRect(handles[i].x, handles[i].y, handles[i].width - 1, handles[i].height - 1); } } } }
Example 11
Project: incubator-netbeans File: SheetTable.java View Source Code | 4 votes |
/** Paint the expandable sets. These are painted double width, * across the entire width of the table. */ private void paintExpandableSets(Graphics g) { int start = 0; int end = getRowCount(); Insets ins = getInsets(); boolean canBeSelected = isKnownComponent( KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() ); for (int i = 0; i < end; i++) { int idx = start + i; Object value = getValueAt(idx, 0); if (value instanceof PropertySet) { Rectangle r = getCellRect(idx, 0, false); r.x = ins.left; r.width = getWidth() - (ins.left + ins.right); if (g.hitClip(r.x, r.y, r.width, r.height)) { PropertySet ps = (PropertySet) value; String txt = ps.getHtmlDisplayName(); boolean isHtml = txt != null; if (!isHtml) { txt = ps.getDisplayName(); } if (htmlrenderer == null) { htmlrenderer = HtmlRenderer.createRenderer(); } JComponent painter = (JComponent) htmlrenderer.getTableCellRendererComponent( this, txt, false, false, idx, 0 ); htmlrenderer.setHtml(isHtml); htmlrenderer.setParentFocused(true); htmlrenderer.setIconTextGap(2); htmlrenderer.setIcon( getPropertySetModel().isExpanded(ps) ? PropUtils.getExpandedIcon() : PropUtils.getCollapsedIcon() ); boolean selected = canBeSelected && (getSelectedRow() == idx); if (!selected) { painter.setBackground(PropUtils.getSetRendererColor()); painter.setForeground(PropUtils.getSetForegroundColor()); } else { painter.setBackground(PropUtils.getSelectedSetRendererColor()); painter.setForeground(PropUtils.getSelectedSetForegroundColor()); } if( PropUtils.isAqua ) { painter.setOpaque(false); Graphics2D g2d = (Graphics2D) g; Paint oldPaint = g2d.getPaint(); g2d.setPaint( new GradientPaint(r.x,r.y, Color.white, r.x, r.y+r.height/2, painter.getBackground()) ); g2d.fillRect(r.x, r.y, r.width, r.height); g2d.setPaint(oldPaint); } else { painter.setOpaque(true); } paintComponent(g, painter, r.x, r.y, r.width, r.height); } } } }