List of usage examples for java.awt Graphics fillOval
public abstract void fillOval(int x, int y, int width, int height);
From source file:ClipDemo.java
public void paintComponent(Graphics g) { super.paintComponent(g); // get damaged region Rectangle clipRect = g.getClipBounds(); int clipx = clipRect.x; int clipy = clipRect.y; int clipw = clipRect.width; int cliph = clipRect.height; // fill damaged region only g.setColor(Color.white);/*w ww.j a v a 2 s.co m*/ g.fillRect(clipx, clipy, clipw, cliph); if (clipx <= 240 && clipy <= 240) { g.setColor(Color.yellow); g.fillOval(0, 0, 240, 240); System.out.println(" yellow Oval repainted."); } if (clipx + clipw >= 160 && clipx <= 400 && clipy + cliph >= 160 && clipy <= 400) { g.setColor(Color.magenta); g.fillOval(160, 160, 240, 240); System.out.println(" magenta Oval repainted."); } int iconWidth = java2sLogo.getIconWidth(); int iconHeight = java2sLogo.getIconHeight(); if (clipx + clipw >= 280 - (iconWidth / 2) && clipx <= (280 + (iconWidth / 2)) && clipy + cliph >= 120 - (iconHeight / 2) && clipy <= (120 + (iconHeight / 2))) { java2sLogo.paintIcon(this, g, 280 - (iconWidth / 2), 120 - (iconHeight / 2)); System.out.println(" logo below blue Rect repainted."); } if (clipx + clipw >= 120 - (iconWidth / 2) && clipx <= (120 + (iconWidth / 2)) && clipy + cliph >= 280 - (iconHeight / 2) && clipy <= (280 + (iconHeight / 2))) { java2sLogo.paintIcon(this, g, 120 - (iconWidth / 2), 280 - (iconHeight / 2)); System.out.println(" logo below red Rect repainted."); } if (clipx + clipw >= 60 && clipx <= 180 && clipy + cliph >= 220 && clipy <= 340) { g.setColor(red); g.fillRect(60, 220, 120, 120); System.out.println(" red Rect repainted."); } if (clipx + clipw > 140 && clipx < 260 && clipy + cliph > 140 && clipy < 260) { g.setColor(green); g.fillOval(140, 140, 120, 120); System.out.println(" green Oval repainted."); } if (clipx + clipw > 220 && clipx < 380 && clipy + cliph > 60 && clipy < 180) { g.setColor(blue); g.fillRect(220, 60, 120, 120); System.out.println(" blue Rect repainted."); } g.setColor(Color.black); g.setFont(monoFont); FontMetrics fm = g.getFontMetrics(); iconWidth = fm.stringWidth("Java Source"); iconHeight = fm.getAscent(); int d = fm.getDescent(); if (clipx + clipw > 120 - (iconWidth / 2) && clipx < (120 + (iconWidth / 2)) && clipy + cliph > (120 + (iconHeight / 4)) - iconHeight && clipy < (120 + (iconHeight / 4)) + d) { g.drawString("Java Source", 120 - (iconWidth / 2), 120 + (iconHeight / 4)); System.out.println(" Java Source repainted."); } g.setFont(sanFont); fm = g.getFontMetrics(); iconWidth = fm.stringWidth("and"); iconHeight = fm.getAscent(); d = fm.getDescent(); if (clipx + clipw > 200 - (iconWidth / 2) && clipx < (200 + (iconWidth / 2)) && clipy + cliph > (200 + (iconHeight / 4)) - iconHeight && clipy < (200 + (iconHeight / 4)) + d) { g.drawString("and", 200 - (iconWidth / 2), 200 + (iconHeight / 4)); System.out.println(" and repainted."); } g.setFont(serifFont); fm = g.getFontMetrics(); iconWidth = fm.stringWidth("Support."); iconHeight = fm.getAscent(); d = fm.getDescent(); if (clipx + clipw > 280 - (iconWidth / 2) && clipx < (280 + (iconWidth / 2)) && clipy + cliph > (280 + (iconHeight / 4)) - iconHeight && clipy < (280 + (iconHeight / 4)) + d) { g.drawString("Support.", 280 - (iconWidth / 2), 280 + (iconHeight / 4)); System.out.println(" Support. repainted."); } }
From source file:FillRectPanel.java
public void paintComponent(Graphics g) { super.paintComponent(g); g.drawRect(10, 10, 80, 30);/*from www . j av a2 s . c o m*/ g.drawRoundRect(100, 10, 80, 30, 15, 15); g.drawOval(10, 100, 80, 30); g.setColor(Color.red); g.fillRect(10, 10, 80, 30); g.fillRoundRect(100, 10, 80, 30, 15, 15); int thickness = 4; g.fill3DRect(200, 10, 80, 30, true); for (int i = 1; i <= thickness; i++) g.draw3DRect(200 - i, 10 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true); g.fill3DRect(200, 50, 80, 30, false); for (int i = 1; i <= thickness; i++) g.draw3DRect(200 - i, 50 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true); g.fillOval(10, 100, 80, 30); }
From source file:de.unidue.inf.is.ezdl.gframedl.tools.relations.DLObjectGraphView.java
private void setRenderers() { vv.getRenderContext().setVertexLabelTransformer(new Transformer<DLObject, String>() { @Override/*from w w w .j a va 2 s . co m*/ public String transform(DLObject v) { String result = ""; if (v instanceof Person) { result = ((Person) v).getFirstName() + " " + ((Person) v).getLastName(); } if (v instanceof TextDocument) { result = ((TextDocument) v).getTitle(); } return result; } }); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.red)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); vv.getRenderContext().setVertexShapeTransformer(new VertexShapeFunction<DLObject>()); vv.getRenderContext().setVertexIconTransformer(new Transformer<DLObject, Icon>() { @Override public Icon transform(final DLObject v) { final int size = getVertexSize(v); return new Icon() { @Override public int getIconHeight() { return size; } @Override public int getIconWidth() { return size; } @Override public void paintIcon(Component c, Graphics g, int x, int y) { int halfSize = size / 2; if (vv.getPickedVertexState().isPicked(v)) { g.setColor(Color.yellow); } else { g.setColor(Color.lightGray); } g.fillOval(x, y, size, size); if (vv.getPickedVertexState().isPicked(v)) { g.setColor(Color.red); } else { g.setColor(Color.black); } g.drawOval(x, y, size, size); int iconX = x + halfSize - 8; int iconY = y + halfSize - 8; if (v instanceof Person) { Icons.MEDIA_AUTHOR.get16x16().paintIcon(c, g, iconX, iconY); } if (v instanceof TextDocument) { Icons.MEDIA_TEXT.get16x16().paintIcon(c, g, iconX, iconY); } if (v instanceof Term) { Icons.MEDIA_TERM.get16x16().paintIcon(c, g, iconX, iconY); } } }; } }); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.black)); vv.setBackground(Color.white); }
From source file:rod_design_compute.ShowPanel.java
private void drawJunctionPoint(Point point, Graphics g) { int x = toScreenX(point.X); int y = toScreenY(point.Y); g.setColor(Color.white);/*w ww .j av a 2 s.c o m*/ g.fillOval(x - radiusBase, y - radiusBase, radiusBase * 2, radiusBase * 2); g.setColor(Color.black); g.drawOval(x - radiusBase, y - radiusBase, radiusBase * 2, radiusBase * 2); }
From source file:rod_design_compute.ShowPanel.java
private void drawOtherPoint(Point point, Graphics g) { int x = toScreenX(point.X); int y = toScreenY(point.Y); g.setColor(Color.white);//from w w w .ja v a2 s.co m g.fillOval(x - radiusBase, y - radiusBase, radiusBase * 2, radiusBase * 2); g.setColor(Color.red); g.drawOval(x - radiusBase, y - radiusBase, radiusBase * 2, radiusBase * 2); }
From source file:rod_design_compute.ShowPanel.java
private void drawChoosePoint(Point point, Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(new BasicStroke(2f)); int x = toScreenX(point.X); int y = toScreenY(point.Y); g.setColor(Color.blue);/*w w w . j a va 2 s . c om*/ g.fillOval(x - radiusBase, y - radiusBase, radiusBase * 2, radiusBase * 2); }
From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java
private void drawFriedEgg(final Graphics g, final int x, final int y, final Color c1, final Color c2) { g.setColor(c1);/*from w w w. j a v a 2 s . c o m*/ g.fillOval(x - SELECTED_NODE_DRAWING_SIZE / 2, y - SELECTED_NODE_DRAWING_SIZE / 2, SELECTED_NODE_DRAWING_SIZE, SELECTED_NODE_DRAWING_SIZE); g.setColor(c2); g.fillOval(x - SELECTED_NODE_INTERNAL_SIZE / 2, y - SELECTED_NODE_INTERNAL_SIZE / 2, SELECTED_NODE_INTERNAL_SIZE, SELECTED_NODE_INTERNAL_SIZE); }
From source file:CustomAlphaTest.java
protected void drawGraphFillCircle(Graphics g, double x1, double y1, double radius) { g.fillOval((int) (m_nGraphInsetX + x1 - radius), (int) (m_nGraphInsetY + m_nGraphMaxHeight - y1 - radius), (int) (radius * 2), (int) (radius * 2)); }
From source file:edu.mit.fss.tutorial.part4.ControlPanel.java
@Override public void paint(Graphics g) { // Calls the super-class paint method for the default background. super.paint(g); // Set color to gray and draw the x-axis (Y=0) and y=axis (X=0). g.setColor(Color.gray);// w w w .ja va 2 s . com g.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2); g.drawLine(getWidth() / 2, 0, getWidth() / 2, getHeight()); // Make sure no changes to elements can take place while painting. synchronized (elements) { // For each surface element... for (SurfaceElement e : elements) { if (e instanceof MobileElement) { // If it is a MobileElement, use blue color. g.setColor(Color.blue); } else { // Otherwise use black color. g.setColor(Color.black); } // Determine the screen location for the element. int[] location = getScreenLocation(e.getPosition()); // Fill an oval at the location (offset by half the oval size). g.fillOval(location[0] - ELEMENT_SIZE / 2, location[1] - ELEMENT_SIZE / 2, ELEMENT_SIZE, ELEMENT_SIZE); // Draw the element name to the right of the oval, offset by // 2 pixels to the right and half the oval size vertically. g.drawString(e.getName(), location[0] + ELEMENT_SIZE / 2 + 2, location[1] + ELEMENT_SIZE / 2 + ELEMENT_SIZE / 2); } } }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * Creates the center panel./*from www. j av a 2s . com*/ * * @return the created center panel */ private Container createCenter() { JPanel centerPanel = new JPanel(new GridBagLayout()); centerPanel.setBackground(Color.WHITE); centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 3)); GridBagConstraints constraints = new GridBagConstraints(); initSmsLabel(centerPanel); initTextArea(centerPanel); smsCharCountLabel = new JLabel(String.valueOf(smsCharCount)); smsCharCountLabel.setForeground(Color.GRAY); smsCharCountLabel.setVisible(false); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 0; constraints.weightx = 0f; constraints.weighty = 0f; constraints.insets = new Insets(0, 2, 0, 2); constraints.gridheight = 1; constraints.gridwidth = 1; centerPanel.add(smsCharCountLabel, constraints); smsNumberLabel = new JLabel(String.valueOf(smsNumberCount)) { @Override public void paintComponent(Graphics g) { AntialiasingManager.activateAntialiasing(g); g.setColor(getBackground()); g.fillOval(0, 0, getWidth(), getHeight()); super.paintComponent(g); } }; smsNumberLabel.setHorizontalAlignment(JLabel.CENTER); smsNumberLabel.setPreferredSize(new Dimension(18, 18)); smsNumberLabel.setMinimumSize(new Dimension(18, 18)); smsNumberLabel.setForeground(Color.WHITE); smsNumberLabel.setBackground(Color.GRAY); smsNumberLabel.setVisible(false); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 0; constraints.weightx = 0f; constraints.weighty = 0f; constraints.insets = new Insets(0, 2, 0, 2); constraints.gridheight = 1; constraints.gridwidth = 1; centerPanel.add(smsNumberLabel, constraints); return centerPanel; }