Java Code Examples for java.awt.Graphics2D#drawRect()
The following examples show how to use
java.awt.Graphics2D#drawRect() .
These examples are extracted from open source projects.
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 Project: energy2d File: Symbol.java License: GNU Lesser General Public License v3.0 | 6 votes |
public void paintIcon(Component c, Graphics g, int x, int y) { super.paintIcon(c, g, x, y); int y2 = Math.round(ySymbol + hSymbol * 0.5f); Graphics2D g2 = (Graphics2D) g; if (isButtonIcon) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } g2.setColor(Color.white); g2.fillRect(xSymbol, ySymbol, wSymbol, hSymbol); g2.fillOval(xSymbol - 7, y2 - 3, 6, 6); g2.setColor(Color.black); g2.drawRect(xSymbol, ySymbol, wSymbol, hSymbol); for (int i = 4; i < wSymbol - 4; i += 4) { if (i % 8 == 0) { g2.drawLine(xSymbol + i, ySymbol, xSymbol + i + 4, ySymbol + hSymbol); } else { g2.drawLine(xSymbol + i, ySymbol + hSymbol, xSymbol + i + 4, ySymbol); } } g2.drawLine(xSymbol - 2, y2, xSymbol + 4, y2); g2.drawOval(xSymbol - 7, y2 - 3, 6, 6); g2.setStroke(stroke2); g2.drawLine(xSymbol, ySymbol, xSymbol + wSymbol, ySymbol); g2.drawLine(xSymbol, ySymbol + hSymbol, xSymbol + wSymbol, ySymbol + hSymbol); }
Example 2
Source Project: seaglass File: SeaGlassBrowser.java License: Apache License 2.0 | 6 votes |
static void printDimension(PrintWriter html, Dimension dim) { html.println("<td>Dimension (" + dim.width + "," + dim.height + ")</pre></td>"); int w = dim.width; int h = dim.height; if (w == 0 || h == 0) { html.println("<td> </td>"); } else { BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = img.createGraphics(); Composite old = g2.getComposite(); g2.setComposite(AlphaComposite.Clear); g2.fillRect(0, 0, w, h); g2.setComposite(old); g2.setColor(Color.RED); g2.drawRect(0, 0, w - 1, h - 1); g2.dispose(); html.println("<td>" + saveImage(img) + "</td>"); } }
Example 3
Source Project: brModelo File: FormaRetangular.java License: GNU General Public License v3.0 | 6 votes |
@Override public void DoPaint(Graphics2D g) { getTextoFormatado().CorretorPosicao = new Point(-1, -1); g.setPaint(this.getForeColor()); super.DoPaint(g); g.drawRect(getLeft(), getTop(), getWidth() -1, getHeight() -1); Paint bkp = g.getPaint(); g.setPaint(isDisablePainted()? disabledColor : Color.darkGray); int L = getLeft(); int T = getTop(); int W = getWidth() + L; int H = getHeight() + T; g.drawLine(L + 1, H, W, H); g.drawLine(W, T + 1, W, H); g.setPaint(isDisablePainted()? disabledColor : Color.gray); g.drawLine(L + 2, H + 1, W + 1, H + 1); g.drawLine(W + 1, T + 2, W +1, H + 1); // g.drawLine(L + 1, H -1, W -1, H -1); // g.drawLine(W -1, T + 1, W -1, H -1); // g.setPaint(Color.gray); // g.drawLine(L + 2, H, W, H); // g.drawLine(W, T + 2, W, H); g.setPaint(bkp); //g.drawString(getLocation().toString(), getLeft() + 5, getTop() + 20); }
Example 4
Source Project: jdk8u_jdk File: RepaintManagerFPUIScaleTest.java License: GNU General Public License v2.0 | 6 votes |
private static Image createTestImage(int w, int h, double scaleX, double scaleY, Color color) { int width = (int) Math.ceil(scaleX * w); int height = (int) Math.ceil(scaleY * h); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = img.createGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); g.scale(scaleX, scaleY); g.setColor(color); int d = 1; int d2 = 2 * d; g.drawLine(d, h / 2, w - d2, h / 2); g.drawLine(w / 2, d, w / 2, h - d2); g.drawRect(d, d, w - d2, h - d2); g.dispose(); return img; }
Example 5
Source Project: chipster File: RectDrawable.java License: MIT License | 6 votes |
public void draw(Graphics2D g, int x, int y) { super.draw(g, x, y); // Draw fill if (this.color != null) { g.setPaint(this.color); g.fillRect(this.x + x, this.y + y, this.width, this.height); } // Draw outline after fill to hide gaps between adjacent rectangles if (this.lineColor != null) { g.setColor(this.lineColor); g.drawRect(this.x + x, this.y + y, this.width - 1, this.height - 1); } }
Example 6
Source Project: 3Dscript File: SingleSlider.java License: BSD 2-Clause "Simplified" License | 6 votes |
@Override public void paintBuffer(Graphics gx) { Graphics2D g = (Graphics2D)gx; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.clearRect(0, 0, getWidth(), getHeight()); g.setColor(color); int x1 = diagram.canvasX(setMax); int wi = x1 - 0; g.fillRect(0, diagram.getTopPixel() - 1, wi, diagram.getAvailableHeight() + 1); g.setColor(Color.BLACK); g.drawRect(0, diagram.getTopPixel() - 1, wi, diagram.getAvailableHeight() + 1); g.setColor(Color.BLACK); diagram.drawFrame(gx); }
Example 7
Source Project: render File: ClusterOverlapProblem.java License: GNU General Public License v2.0 | 6 votes |
private static void drawTileBounds(final Graphics2D targetGraphics, final RenderParameters renderParameters, final TileBounds tileBounds, final Color color) { targetGraphics.setStroke(new BasicStroke(2)); targetGraphics.setColor(color); final int x = (int) ((tileBounds.getMinX() - renderParameters.getX()) * renderParameters.getScale()); final int y = (int) ((tileBounds.getMinY() - renderParameters.getY()) * renderParameters.getScale()); final int width = (int) (tileBounds.getDeltaX() * renderParameters.getScale()); final int height = (int) (tileBounds.getDeltaY() * renderParameters.getScale()); // HACK: draw row and column label for FAFB style tileIds final String tileId = tileBounds.getTileId(); final int firstDot = tileId.indexOf('.'); if (firstDot > 6) { final String rowAndColumn = tileId.substring(firstDot - 6, firstDot); targetGraphics.drawString(rowAndColumn, (x + 10), (y + 20)); } targetGraphics.drawRect(x, y, width, height); }
Example 8
Source Project: rscplus File: Renderer.java License: GNU General Public License v3.0 | 5 votes |
public static void drawShadowTextBorder( Graphics2D g, String text, int x, int y, Color textColor, float alpha, float boxAlpha, boolean border, int borderSize) { int textX = x; int textY = y; Dimension bounds = getStringBounds(g, text); textX -= (bounds.width / 2); textY += (bounds.height / 2); g.setColor(color_shadow); int rectX = x - (bounds.width / 2) - 2 - borderSize; int rectY = y - (bounds.height / 2) + 2 - borderSize; int rectWidth = bounds.width + 2 + (borderSize * 2); int rectHeight = bounds.height + (borderSize * 2); if (border) { setAlpha(g, 1.0f); g.drawRect(rectX, rectY, rectWidth, rectHeight); } setAlpha(g, boxAlpha); g.fillRect(rectX, rectY, rectWidth, rectHeight); setAlpha(g, alpha); g.drawString(text, textX + 1, textY); g.drawString(text, textX - 1, textY); g.drawString(text, textX, textY + 1); g.drawString(text, textX, textY - 1); g.setColor(textColor); g.drawString(text, textX, textY); }
Example 9
Source Project: object-recognition-tensorflow File: TableLayout.java License: Apache License 2.0 | 5 votes |
void drawDebug () { Graphics2D g = (Graphics2D)getTable().getGraphics(); if (g == null) return; g.setColor(Color.red); for (DebugRect rect : debugRects) { if (rect.type == Debug.cell) g.setColor(Color.red); if (rect.type == Debug.widget) g.setColor(Color.green); if (rect.type == Debug.table) g.setColor(Color.blue); g.drawRect(rect.x, rect.y, rect.width, rect.height); } }
Example 10
Source Project: visualvm File: DisplayAreaSupport.java License: GNU General Public License v2.0 | 5 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension size = getSize(); Graphics2D g2 = (Graphics2D)g; if( hasFocus() && isEnabled() ) { g2.setStroke(TABBUTTON_FOCUS_STROKE); g2.setColor(TABBUTTON_FOCUS_COLOR); g2.drawRect(2, 2, size.width - 5, size.height - 5); } }
Example 11
Source Project: ChatGameFontificator File: ColorSwatch.java License: The Unlicense | 5 votes |
@Override public void paint(Graphics g) { super.paint(g); if (isSelected()) { Graphics2D g2d = (Graphics2D) g; g2d.setPaint(Color.BLACK); Stroke stroke = new BasicStroke(BORDER_THICKNESS, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 3, 3, 3, 3 }, dashTimer.getOffset()); g2d.setStroke(stroke); final int halfThickness = Math.max(1, BORDER_THICKNESS / 2); g2d.drawRect(halfThickness, halfThickness, getWidth() - BORDER_THICKNESS, getHeight() - BORDER_THICKNESS); } }
Example 12
Source Project: PyramidShader File: BivariateColorPanel.java License: GNU General Public License v3.0 | 4 votes |
@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; if (getRenderer() != null) { //Antialiasing ON g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ArrayList<BivariateColorPoint> points = getRenderer().getPoints(); for (BivariateColorPoint point : points) { int px = attr1ToPixelX(point.getAttribute1()); int py = attr2ToPixelY(point.getAttribute2()); g2d.setColor(point.getColor()); if (point.isLonLatDefined()) { g2d.fillOval(px - RECT_DIM / 2, py - RECT_DIM / 2, RECT_DIM, RECT_DIM); } else { g2d.fillRect(px - RECT_DIM / 2, py - RECT_DIM / 2, RECT_DIM, RECT_DIM); } if (point == selectedPoint) { if (ColorUtils.difference(Color.RED, point.getColor()) > 100) { g2d.setColor(Color.RED); } else { g2d.setColor(Color.CYAN); } } else { if (ColorUtils.getBrightness(point.getColor()) > 100) { g2d.setColor(Color.BLACK); } else { g2d.setColor(Color.WHITE); } } if (point.isLonLatDefined()) { g2d.drawOval(px - RECT_DIM / 2, py - RECT_DIM / 2, RECT_DIM, RECT_DIM); } else { g2d.drawRect(px - RECT_DIM / 2, py - RECT_DIM / 2, RECT_DIM, RECT_DIM); } } int D = 3; g2d.setColor(Color.BLACK); if (crossXPerc >= 0 && crossYPerc >= 0) { int x = (int) Math.round(crossXPerc * getWidth() / 100d); int y = (int) Math.round(crossYPerc * getHeight() / 100d); g2d.drawLine(x - D, y, x + D, y); g2d.drawLine(x, y - D, x, y + D); } } paintWarningString(g2d); }
Example 13
Source Project: open-ig File: InfoScreen.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Override public void draw(Graphics2D g2) { int rowCount = (height + rowHeight - 1) / rowHeight; int columnWidth = width / columns; List<BuildingType> planets = getList.invoke(null); Map<BuildingType, Integer> counts = player().countBuildings(); Map<BuildingType, Integer> current = planet().countBuildings(); boolean showCounts = planet().owner == player() || knowledge(planet(), PlanetKnowledge.BUILDING) >= 0 || (knowledge(planet(), PlanetKnowledge.OWNER) >= 0 && !planet().isPopulated()); for (int j = 0; j < columns; j++) { int x0 = j * columnWidth; for (int i = 0; i < rowCount; i++) { int y0 = i * rowHeight; int pidx = (j + columnIndex) * rowCount + i; if (pidx >= 0 && pidx < planets.size()) { BuildingType p = planets.get(pidx); int c = TextRenderer.GRAY; if (planet().canBuild(p) && planet().owner == player()) { if (p.cost > player().money()) { c = 0xFFFF8080; } else { c = TextRenderer.YELLOW; } } String t = p.name; commons.text().paintTo(g2, x0 + 30, y0 + 2, fontSize, c, t); if (showCounts) { Integer c0 = current.get(p); Integer c1 = counts.get(p); String n = (c0 != null ? c0 : 0) + "/" + (c1 != null ? c1 : 0); int col = c1 != null ? TextRenderer.GREEN : TextRenderer.GRAY; commons.text().paintTo(g2, x0, y0 + 4, 7, col, n); } if (p == player().currentBuilding) { g2.setColor(new Color(player().color)); g2.drawRect(x0 - 2 + 30, y0, columnWidth - 30, rowHeight); } } } } }
Example 14
Source Project: birt File: Regression_117699_swing.java License: Eclipse Public License 1.0 | 4 votes |
/** * Presents the Exceptions if the chart cannot be displayed properly. * * @param g2d * @param ex */ private final void showException( Graphics2D g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Dimension d = getSize( ); Font fo = new Font( "Monospaced", Font.BOLD, 14 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setColor( Color.WHITE ); g2d.fillRect( 20, 20, d.width - 40, d.height - 40 ); g2d.setColor( Color.BLACK ); g2d.drawRect( 20, 20, d.width - 40, d.height - 40 ); g2d.setClip( 20, 20, d.width - 40, d.height - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Exception:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.RED ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setColor( Color.BLACK ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Wrapped In:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.RED ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setColor( Color.BLACK ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Message:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.BLUE ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setColor( Color.BLACK ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setColor( Color.GREEN.darker( ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } }
Example 15
Source Project: birt File: Regression_116619_swing.java License: Eclipse Public License 1.0 | 4 votes |
/** * Presents the Exceptions if the chart cannot be displayed properly. * * @param g2d * @param ex */ private final void showException( Graphics2D g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Dimension d = getSize( ); Font fo = new Font( "Monospaced", Font.BOLD, 14 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setColor( Color.WHITE ); g2d.fillRect( 20, 20, d.width - 40, d.height - 40 ); g2d.setColor( Color.BLACK ); g2d.drawRect( 20, 20, d.width - 40, d.height - 40 ); g2d.setClip( 20, 20, d.width - 40, d.height - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Exception:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.RED ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setColor( Color.BLACK ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Wrapped In:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.RED ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setColor( Color.BLACK ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += fm.stringWidth( "Message:" ) + 5;//$NON-NLS-1$ g2d.setColor( Color.BLUE ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setColor( Color.BLACK ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setColor( Color.GREEN.darker( ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } }
Example 16
Source Project: openAGV File: BitmapFigure.java License: Apache License 2.0 | 4 votes |
@Override protected void drawStroke(Graphics2D g) { Rectangle r = displayBox(); g.drawRect(r.x, r.y, r.width - 1, r.height - 1); }
Example 17
Source Project: netbeans File: Paper.java License: Apache License 2.0 | 4 votes |
@Override public void paint(Graphics graphics) { Graphics2D g = Config.getDefault().getGraphics(graphics); // scaling if (myIsPainting) { g.scale(myScale, myScale); } // background g.setColor(Color.white); g.fillRect(myPageX, myPageY, myPageWidth, myPageHeight); // page g.translate(myPageX, myPageY); myPage.print(g); g.translate(-myPageX, -myPageY); // horizontal margin g.setColor(Color.white); g.fillRect(0, 0, myPaperWidth, myPageY); g.fillRect(0, myPageY + myPageHeight, myPaperWidth, myPaperHeight); // header if (myHasHeader) { drawTitle(g, myHeaderLeft, myHeaderCenter, myHeaderRight, myHeaderY, myHeaderColor, myHeaderFont); } // footer if (myHasFooter) { drawTitle(g, myFooterLeft, myFooterCenter, myFooterRight, myFooterY, myFooterColor, myFooterFont); } // vertical margin g.setColor(Color.white); g.fillRect(0, 0, myPageX, myPaperHeight); g.fillRect(myPageX + myPageWidth, 0, myPaperWidth, myPaperHeight); // shadow if (myIsPainting) { g.setColor(Color.gray.darker()); g.fillRect(myPaperWidth, SHADOW_WIDTH, SHADOW_WIDTH + 1, myPaperHeight); g.fillRect(SHADOW_WIDTH, myPaperHeight, myPaperWidth, SHADOW_WIDTH + 1); g.setColor(Color.lightGray); g.fillRect(myPaperWidth, 0, SHADOW_WIDTH + 1, SHADOW_WIDTH + 1); g.fillRect(0, myPaperHeight, SHADOW_WIDTH + 1, SHADOW_WIDTH + 1); } // box if (myIsPainting) { g.setColor(Color.black); g.drawRect(0, 0, myPaperWidth, myPaperHeight); } // border if (myHasBorder) { g.setColor(myBorderColor); g.drawRect(myPageX, myPageY, myPageWidth, myPageHeight); } // number if (myIsPainting) { g.setColor(NUMBER_FONT_COLOR); g.setFont(NUMBER_FONT_NAME); g.drawString(Integer.toString(myNumber), NUMBER_X, NUMBER_Y); } }
Example 18
Source Project: Logisim File: AbstractTtlGate.java License: GNU General Public License v3.0 | 4 votes |
protected void paintBase(InstancePainter painter, boolean drawname, boolean ghost) { Direction dir = painter.getAttributeValue(StdAttr.FACING); Graphics2D g = (Graphics2D) painter.getGraphics(); Bounds bds = painter.getBounds(); int x = bds.getX(); int y = bds.getY(); int xp = x, yp = y; int width = bds.getWidth(); int height = bds.getHeight(); for (byte i = 0; i < this.pinnumber; i++) { if (i < this.pinnumber / 2) { if (dir == Direction.WEST || dir == Direction.EAST) xp = i * 20 + (10 - pinwidth / 2) + x; else yp = i * 20 + (10 - pinwidth / 2) + y; } else { if (dir == Direction.WEST || dir == Direction.EAST) { xp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + x; yp = height + y - pinheight; } else { yp = (i - this.pinnumber / 2) * 20 + (10 - pinwidth / 2) + y; xp = width + x - pinheight; } } if (dir == Direction.WEST || dir == Direction.EAST) { // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRect(xp, yp, pinwidth, pinheight); g.setColor(Color.BLACK); } g.drawRect(xp, yp, pinwidth, pinheight); } else { // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRect(xp, yp, pinheight, pinwidth); g.setColor(Color.BLACK); } g.drawRect(xp, yp, pinheight, pinwidth); } } if (dir == Direction.SOUTH) { // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRoundRect(x + pinheight, y, bds.getWidth() - pinheight * 2, bds.getHeight(), 10, 10); g.setColor(Color.BLACK); } g.drawRoundRect(x + pinheight, y, bds.getWidth() - pinheight * 2, bds.getHeight(), 10, 10); g.drawArc(x + width / 2 - 7, y - 7, 14, 14, 180, 180); } else if (dir == Direction.WEST) { // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRoundRect(x, y + pinheight, bds.getWidth(), bds.getHeight() - pinheight * 2, 10, 10); g.setColor(Color.BLACK); } g.drawRoundRect(x, y + pinheight, bds.getWidth(), bds.getHeight() - pinheight * 2, 10, 10); g.drawArc(x + width - 7, y + height / 2 - 7, 14, 14, 90, 180); } else if (dir == Direction.NORTH) { // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRoundRect(x + pinheight, y, bds.getWidth() - pinheight * 2, bds.getHeight(), 10, 10); g.setColor(Color.BLACK); } g.drawRoundRect(x + pinheight, y, bds.getWidth() - pinheight * 2, bds.getHeight(), 10, 10); g.drawArc(x + width / 2 - 7, y + height - 7, 14, 14, 0, 180); } else {// east // fill the background of white if selected from preferences if (!ghost && AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) { g.setColor(Color.WHITE); g.fillRoundRect(x, y + pinheight, bds.getWidth(), bds.getHeight() - pinheight * 2, 10, 10); g.setColor(Color.BLACK); } g.drawRoundRect(x, y + pinheight, bds.getWidth(), bds.getHeight() - pinheight * 2, 10, 10); g.drawArc(x - 7, y + height / 2 - 7, 14, 14, 270, 180); } g.rotate(Math.toRadians(-dir.toDegrees()), x + width / 2, y + height / 2); if (drawname) { g.setFont(new Font(Font.DIALOG_INPUT, Font.BOLD, 14)); GraphicsUtil.drawCenteredText(g, this.name, x + bds.getWidth() / 2, y + bds.getHeight() / 2 - 4); } if (dir == Direction.WEST || dir == Direction.EAST) { xp = x; yp = y; } else { xp = x + (width - height) / 2; yp = y + (height - width) / 2; width = bds.getHeight(); height = bds.getWidth(); } g.setFont(new Font(Font.DIALOG_INPUT, Font.BOLD, 7)); GraphicsUtil.drawCenteredText(g, "Vcc", xp + 10, yp + pinheight + 4); GraphicsUtil.drawCenteredText(g, "GND", xp + width - 10, yp + height - pinheight - 7); }
Example 19
Source Project: whyline File: WhylineMenuBorder.java License: MIT License | 3 votes |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setColor(UI.getControlBorderColor()); g2.drawRect(0, 0, width - 1, height - 1); }
Example 20
Source Project: ET_Redux File: KwikiSynopticOutputPanel.java License: Apache License 2.0 | 2 votes |
private void DrawBounds ( Graphics2D g2d ) { g2d.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 ); }