List of usage examples for java.awt Graphics drawRect
public void drawRect(int x, int y, int width, int height)
From source file:FileTree3.java
public void paintComponent(Graphics g) { Color bColor = getBackground(); Icon icon = getIcon();/* w w w. j a v a2 s. c om*/ g.setColor(bColor); int offset = 0; if (icon != null && getText() != null) offset = (icon.getIconWidth() + getIconTextGap()); g.fillRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1); if (m_selected) { g.setColor(m_borderSelectionColor); g.drawRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1); } super.paintComponent(g); }
From source file:org.deegree.ogcwebservices.wms.dataaccess.ID2PInterpolation.java
public BufferedImage perform(GetLegendGraphic glg) { BufferedImage bi = new BufferedImage(150, colorMap.size() * 25, BufferedImage.TYPE_4BYTE_ABGR); Iterator<double[]> iterator = colorMap.keySet().iterator(); List<double[]> list = new ArrayList<double[]>(colorMap.size()); while (iterator.hasNext()) { double[] ds = iterator.next(); list.add(ds);/*from w ww. j a va2 s . com*/ } for (int i = list.size() - 1; 0 <= i; i--) { for (int j = 0; j < i; j++) { if (list.get(j + 1)[0] < list.get(j)[0]) { double[] ds = list.get(j + 1); list.set(j + 1, list.get(j)); list.set(j, ds); } } } int i = 0; Graphics g = bi.getGraphics(); for (double[] ds : list) { Color color = colorMap.get(ds); g.setColor(color); g.fillRect(2, 2 + i * 25, 20, 20); g.setColor(Color.BLACK); g.drawRect(2, 2 + i * 25, 20, 20); g.drawString(Double.toString(ds[0]) + " - " + Double.toString(ds[1]), 25, 17 + i * 25); i++; } g.dispose(); return bi; }
From source file:TrackFocusDemo.java
protected void paintComponent(Graphics graphics) { Graphics g = graphics.create(); //Draw in our entire space, even if isOpaque is false. g.setColor(Color.WHITE);//from w w w .ja v a2s . co m g.fillRect(0, 0, image == null ? 125 : image.getWidth(this), image == null ? 125 : image.getHeight(this)); if (image != null) { //Draw image at its natural size of 125x125. g.drawImage(image, 0, 0, this); } //Add a border, red if picture currently has focus if (isFocusOwner()) { g.setColor(Color.RED); } else { g.setColor(Color.BLACK); } g.drawRect(0, 0, image == null ? 125 : image.getWidth(this), image == null ? 125 : image.getHeight(this)); g.dispose(); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
public void paint(Graphics g) { super.paint(g); // Draw a 2-pixel border g.setColor(Color.black);/*w ww . j a v a 2 s. co m*/ int width = getSize().width; // Width of the applet. int height = getSize().height; // Height of the applet. g.drawRect(0, 0, width - 1, height - 1); g.drawRect(1, 1, width - 3, height - 3); }
From source file:CustomAlphaTest.java
protected void drawAreaRect(Graphics g, int x, int y, int width, int height) { g.drawRect(x, y, width, height); }
From source file:se.llbit.chunky.ui.Minimap.java
@Override public void paintComponent(Graphics g) { super.paintComponent(g); // NB lock the lock ordering here is critical! // we access ChunkMap via Chunky but here we also need to lock Chunky synchronized (chunky) { synchronized (this) { ChunkView mapView = chunky.getMapView(); WorldRenderer renderer = chunky.getWorldRenderer(); World world = chunky.getWorld(); ChunkSelectionTracker selection = chunky.getChunkSelection(); renderer.render(world, mapBuffer, Chunk.biomeRenderer, selection); mapBuffer.renderBuffered(g); renderer.renderPlayer(world, g, view, true); renderer.renderSpawn(world, g, view, true); // draw view rectangle g.setColor(Color.orange); g.drawRect((int) FastMath.round(mapView.x0 - view.x0), (int) FastMath.round(mapView.z0 - view.z0), FastMath.round(mapView.width / (float) mapView.scale), FastMath.round(mapView.height / (float) mapView.scale)); // draw North indicator g.setFont(font);// ww w .j av a2s.c om g.setColor(Color.red); g.drawString("N", view.width / 2 - 4, 12); g.setColor(Color.black); g.drawString(world.levelName(), 10, view.height - 10); } } }
From source file:BeanContainer.java
public void paint(Graphics g) { super.paint(g); if (m_activeBean == null) return;/* w w w.jav a 2 s.c o m*/ Point pt = getLocationOnScreen(); Point pt1 = m_activeBean.getLocationOnScreen(); int x = pt1.x - pt.x - 2; int y = pt1.y - pt.y - 2; int w = m_activeBean.getWidth() + 2; int h = m_activeBean.getHeight() + 2; g.setColor(Color.black); g.drawRect(x, y, w, h); }
From source file:HelloUniverse.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g.drawOval(margin, margin, diameter, diameter); zArea = new Rectangle(margin, margin, diameter, diameter); drawZPip(g2, zAngle);// w w w . j av a 2s . c o m g.drawRect(margin, margin + diameter + space, diameter, thickness); // Y // Wheel yArea = new Rectangle(margin, margin + diameter + space, margin + diameter, thickness + pipOffset); yBackClip = new Rectangle(margin - thickness, margin + diameter + space + thickness, margin + diameter + thickness * 2, thickness); drawYPip(g2, yAngle); g.drawRect(margin + diameter + space, margin, thickness, diameter); // X // Wheel xArea = new Rectangle(margin + diameter + space, margin, thickness + pipOffset, margin + diameter); xBackClip = new Rectangle(margin + diameter + space + thickness, margin - thickness, thickness, margin + diameter + thickness * 2); drawXPip(g2, xAngle); }
From source file:MouseDragClip.java
public void paint(Graphics g) { int w = curX - startX, h = curY - startY; Dimension d = getSize();/*from w ww. j a v a 2 s . c o m*/ if (!inDrag) { // probably first time through(?) g.drawImage(curImage, 0, 0, d.width, d.height, this); return; } System.err.println("paint:drawRect @[" + startX + "," + startY + "] size " + w + "x" + h); // Restore the old background, if previous selection if (oldStartX != -1) { g.setClip(oldStartX, oldStartY, oldWidth + 1, oldHeight + 1); g.drawImage(curImage, 0, 0, d.width, d.height, this); oldStartX = -1; } // Restore the background from previous motions of current drag if (oldX != -1) { g.setClip(startX, startY, w, h); g.drawImage(curImage, 0, 0, d.width + 1, d.height + 1, this); } // Draw the new rectangle g.setClip(0, 0, d.width, d.height); g.setColor(Color.red); g.drawRect(startX, startY, w, h); oldX = curX; oldY = curY; }
From source file:ubic.basecode.graphics.MatrixDisplay.java
/** * @param g//from w w w .java 2 s . co m * @param d */ protected void drawScaleBar(Graphics g, Dimension d, double displayMin, double displayMax) { /* * FIXME this is all a bit of a hack */ g.setColor(Color.white); int upperLeftScalebarGutter = 10; int scaleBarHeight = 10; // these and text height have to total < SCALE_BAR_ROOM int desiredScaleBarLength = (int) Math.min(DEFAULT_SCALE_BAR_WIDTH, d.getWidth()); if (desiredScaleBarLength < 10) { return; } g.drawRect(upperLeftScalebarGutter, upperLeftScalebarGutter, desiredScaleBarLength, upperLeftScalebarGutter); JGradientLabel scalebar = new JGradientLabel(new ColorMap(this.getColorMap()).getPalette()); scalebar.setBackground(Color.white); scalebar.setSize(new Dimension(desiredScaleBarLength, scaleBarHeight)); int actualWidth = scalebar.drawAtLocation(g, upperLeftScalebarGutter, upperLeftScalebarGutter); g.setColor(Color.black); g.drawString(String.format("%.2g", displayMin), 0, upperLeftScalebarGutter + scaleBarHeight + m_fontGutter + g.getFontMetrics().getHeight()); g.drawString(String.format("%.2g", displayMax), actualWidth, upperLeftScalebarGutter + scaleBarHeight + m_fontGutter + g.getFontMetrics().getHeight()); g.drawRect(upperLeftScalebarGutter, upperLeftScalebarGutter, actualWidth, scaleBarHeight); }