List of usage examples for java.awt Graphics drawLine
public abstract void drawLine(int x1, int y1, int x2, int y2);
(x1, y1)
and (x2, y2)
in this graphics context's coordinate system. From source file:Sketch.java
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName() == "value") { Graphics g = board.getGraphics(); g.setColor(getForeground());/* w ww .j a v a 2 s.com*/ g.drawLine(lastX, lastY, shuttle1.getValue(), shuttle2.getValue()); lastX = shuttle1.getValue(); lastY = shuttle2.getValue(); } }
From source file:DialogSeparator.java
public void paint(Graphics g) { g.setColor(getBackground());/*ww w .j a v a 2s . c o m*/ g.fillRect(0, 0, getWidth(), getHeight()); Dimension d = getSize(); int y = (d.height - 3) / 2; g.setColor(Color.white); g.drawLine(1, y, d.width - 1, y); y++; g.drawLine(0, y, 1, y); g.setColor(Color.gray); g.drawLine(d.width - 1, y, d.width, y); y++; g.drawLine(1, y, d.width - 1, y); String text = getText(); if (text.length() == 0) return; g.setFont(getFont()); FontMetrics fm = g.getFontMetrics(); y = (d.height + fm.getAscent()) / 2; int fontWidth = fm.stringWidth(text); g.setColor(getBackground()); g.fillRect(OFFSET - 5, 0, OFFSET + fontWidth, d.height); g.setColor(getForeground()); g.drawString(text, OFFSET, y); }
From source file:MainClass.java
public void print(Graphics g) { Font oldFont = g.getFont();//w w w . ja v a 2 s. co m if (type == TEXT) { g.setFont(font); g.drawString(text, x, y); } else if (type == GRAPHICS) { if (shape.equals("LINE")) { g.drawLine(x, y, width, height); } else if (shape.equals("OVAL")) { g.drawOval(x, y, width, height); } else if (shape.equals("RECTANGLE")) { g.drawRect(x, y, width, height); } } g.setFont(oldFont); }
From source file:RectangleBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color oldColor = g.getColor(); g.setColor(lineColor);//from w w w .j a va2 s .c o m // top for (int i = 0; i < thickness.top; i++) { g.drawLine(x, y + i, x + width, y + i); } // bottom for (int i = 0; i < thickness.bottom; i++) { g.drawLine(x, y + height - i - 1, x + width, y + height - i - 1); } // right for (int i = 0; i < thickness.right; i++) { g.drawLine(x + width - i - 1, y, x + width - i - 1, y + height); } // left for (int i = 0; i < thickness.left; i++) { g.drawLine(x + i, y, x + i, y + height); } g.setColor(oldColor); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(underlineColor == null ? getForeground() : underlineColor); Insets insets = getInsets();// w ww .j a v a 2 s. c o m int left = insets.left; if (getIcon() != null) left += getIcon().getIconWidth() + getIconTextGap(); g.drawLine(left, getHeight() - 1 - insets.bottom, (int) getPreferredSize().getWidth() - insets.right, getHeight() - 1 - insets.bottom); }
From source file:com.cburch.draw.tools.LineTool.java
@Override public void draw(Canvas canvas, Graphics g) { if (active) { Location start = mouseStart; Location end = mouseEnd;//from ww w .ja v a2 s . c o m g.setColor(Color.GRAY); g.drawLine(start.getX(), start.getY(), end.getX(), end.getY()); } }
From source file:com.foudroyantfactotum.mod.fousarchive.midi.generation.MidiImageGeneration.java
public ImmutablePair<String, BufferedImage> buildImage() throws InterruptedException, ExecutionException { final Future<String> name = pool.submit(new LineProcessor(imgX)); final BufferedImage mdbf = new BufferedImage(imgX, imgY, BufferedImage.TYPE_BYTE_GRAY); final Graphics g = mdbf.getGraphics(); g.setColor(Color.BLACK);//from w w w. java2 s . com g.fillRect(0, 0, imgX, imgY); g.setColor(Color.WHITE); for (Line l = lines.take(); l != TERMINATE; l = lines.take()) { g.drawLine(l.note, (int) Math.round(l.tickStart * imgY), l.note, (int) Math.round(l.tickEnd * imgY)); } pool.shutdown(); g.dispose(); return ImmutablePair.of(name.get(), mdbf); }
From source file:EventQueuePanel.java
public void actionPerformed(ActionEvent evt) { Graphics g = getGraphics(); displayPrompt(g, "Click to chooose the first point"); Point p = getClick();/* w w w .ja v a2 s.co m*/ g.drawOval(p.x - 2, p.y - 2, 4, 4); displayPrompt(g, "Click to choose the second point"); Point q = getClick(); g.drawOval(q.x - 2, q.y - 2, 4, 4); g.drawLine(p.x, p.y, q.x, q.y); displayPrompt(g, "Done! Press button the start again."); g.dispose(); }
From source file:raspihomeapp.ParamForm.java
private void drawClock(final Graphics g) { g.setColor(Color.white);// ww w.ja v a2 s . c o m g.drawString("Leistung in W", 1, 8); g.drawString("Uhrzeit", 750, 320); g.drawLine(20, 320, 20, 15); // Y -Achse g.drawLine(10, 310, 790, 310); // X-Achse }
From source file:TextBox3D.java
public synchronized void paint(Graphics g) { FontMetrics fm = g.getFontMetrics(); Dimension size = getSize();//from ww w . j a va2 s .c om int x = (size.width - fm.stringWidth(text)) / 2; int y = (size.height - fm.getHeight()) / 2; g.setColor(SystemColor.control); g.fillRect(0, 0, size.width, size.height); g.setColor(SystemColor.controlShadow); g.drawLine(0, 0, 0, size.height - 1); g.drawLine(0, 0, size.width - 1, 0); g.setColor(SystemColor.controlDkShadow); g.drawLine(0, size.height - 1, size.width - 1, size.height - 1); g.drawLine(size.width - 1, 0, size.width - 1, size.height - 1); g.setColor(SystemColor.controlText); g.drawString(text, x, y); }