/** * Create a new BusyPainterUI. * * @param view The view to create the painter to. */ public BusyPainterUI(Component view) { busyPainter = new SimpleBusyPainter(); busyPainter.setPointShape(new Ellipse2D.Double(0, 0, 20, 20)); busyPainter.setTrajectory( new Ellipse2D.Double( view.getWidth() / 4, view.getHeight() / 4, view.getWidth() / 2, view.getHeight() / 2)); timer = new Timer(200, this); }
@Override protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { super.paintLayer(g2, l); if (isLocked()) { busyPainter.paint(g2, l, l.getWidth(), l.getHeight()); } }
public BusyPainterUI() { busyPainter = new BusyPainter() { protected void doPaint(Graphics2D g, JComponent object, int width, int height) { // // centralize the effect // Rectangle r = busyPainter.getTrajectory().getBounds(); // int tw = width - r.width - 2 * r.x; // int th = height - r.height - 2 * r.y; // g.translate(tw / 2, th / 2); super.doPaint(g, object, width, height); } }; busyPainter.setPointShape(new Ellipse2D.Double(0, 0, 20, 20)); busyPainter.setTrajectory(new Ellipse2D.Double(0, 0, 100, 100)); busyPainter.setPaintCentered(true); timer = new Timer(100, this); }
@Override protected void doPaint(Graphics2D g, Object object, int width, int height) { Rectangle r = getTrajectory().getBounds(); int tw = width - r.width - 2 * r.x; int th = height - r.height - 2 * r.y; g.translate(tw / 2, th / 2); super.doPaint(g, object, width, height); }
// Change the frame for the busyPainter // and mark BusyPainterUI as dirty public void actionPerformed(ActionEvent e) { frameNumber = (frameNumber + 1) % 8; busyPainter.setFrame(frameNumber); // this will repaint the layer setDirty(true); }
@Override public void actionPerformed(ActionEvent e) { busyPainter.setFrame((busyPainter.getFrame() + 1) % 8); setDirty(true); }