static { Stroke stroke = new BasicStroke(2); selectionShape = stroke.createStrokedShape(hitRect); format.setMinimumIntegerDigits(1); format.setMinimumFractionDigits(1); format.setMaximumFractionDigits(2); }
public void paintComponent(Graphics g) { super.paintComponent(g); this.setBackground(Color.WHITE); Graphics2D g2d = (Graphics2D) g; RenderingHints rh = new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHints(rh); for (int i = 0; i < strokes.size(); i++) { Stroke currentStroke = strokes.get(i); g2d.setPaint(currentStroke.getColor()); g2d.setStroke(new BasicStroke(currentStroke.getThickness())); ArrayList<Point2D> currentStrokePoints = currentStroke.getPoints(); for (int j = 1; j < currentStrokePoints.size(); j++) { g2d.drawLine( (int) (currentStrokePoints.get(j - 1).getX() * this.getSize().getWidth()), (int) (currentStrokePoints.get(j - 1).getY() * this.getSize().getHeight()), (int) (currentStrokePoints.get(j).getX() * this.getSize().getWidth()), (int) (currentStrokePoints.get(j).getY() * this.getSize().getHeight())); } } }
public void setStroke(Stroke s) { if (s != null) { m_localGraphicsState.setStroke(s); if (s.equals(m_psGraphicsState.getStroke())) { return; } m_psGraphicsState.setStroke(s); } else { m_localGraphicsState.setStroke(new BasicStroke()); m_psGraphicsState.setStroke(getStroke()); } // ouput postscript here to set stroke. }