package causation.lab.plaf.basic; // packages import javax.swing.*; import javax.swing.plaf.*; import java.awt.*; import java.awt.geom.Ellipse2D; // custom classes import causation.lab.plaf.LatentUI; import causation.lab.Latent; /** *

* The basic L&F for Latents. * Copyright 1999 by David Danks. All rights reserved. *

* * @see Latent * @version 0.9 June 23, 1999 * @author David Danks */ public class BasicLatentUI extends LatentUI { /////////////////// Class Variables /////////////////// private static final Color BACKGROUND = new Color(153, 204, 153); private static final Color HIGHLIGHT_BACKGROUND = new Color(255, 204, 102); private static final Color BORDER = new Color(102, 102, 102, 102); private static final Color TEXT = Color.black; private static final float BORDER_WIDTH = 3; /////////////////// Constructor /////////////////// /** * The basic constructor */ public BasicLatentUI() { ; } /////////////////// Class Methods /////////////////// /** * @return The BasicRandomizerUI for this object */ public static ComponentUI createUI(JComponent c) { return new BasicLatentUI(); } /////////////////// Instance Methods /////////////////// /** * Currently does not do anything */ public void installUI(JComponent c) { ; } /** * Currently does not do anything */ public void uninstallUI(JComponent c) { ; } /** * Paints the Latent into the given Graphics context. Note: If we aren't * using Java 2, nothing will paint, since it tries to use Graphics2D. * @param g The Graphics context for the Latent * @param c The Latent to be drawn */ public void paint(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) return; if (!(c instanceof Latent)) return; Graphics2D g2 = (Graphics2D)g; Latent l = (Latent)c; Ellipse2D e = l.getEllipse(); // draw the ellipse, and its border if (l.isHighlight()) g2.setColor(HIGHLIGHT_BACKGROUND); else g2.setColor(BACKGROUND); g2.fill(e); g2.setColor(BORDER); g2.setStroke(new BasicStroke(BORDER_WIDTH)); g2.draw(e); g2.setStroke(new BasicStroke()); // now, draw the name Point origin = l.getTextOrigin(); String name = l.getName(); g2.setFont(l.getFont()); g2.setColor(TEXT); g2.drawString(name, origin.x, origin.y); } }