Back to index

moin  1.9.0~rc2
AttributeFigure.java
Go to the documentation of this file.
00001 /*
00002  * @(#)AttributeFigure.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import CH.ifa.draw.util.*;
00009 import CH.ifa.draw.framework.*;
00010 import CH.ifa.draw.standard.*;
00011 
00012 import java.awt.*;
00013 import java.util.*;
00014 import java.io.*;
00015 
00025 public abstract class AttributeFigure extends AbstractFigure {
00026 
00034     private static FigureAttributes fgDefaultAttributes = null;
00035 
00036     /*
00037      * Serialization support.
00038      */
00039     private static final long serialVersionUID = -10857585979273442L;
00040     private int attributeFigureSerializedDataVersion = 1;
00041 
00042     protected AttributeFigure() { }
00043 
00048     public void draw(Graphics g, boolean showGuides) {
00049         Color fill = getFillColor();
00050         if (!ColorMap.getColorMap().isTransparent(fill)) {
00051             g.setColor(fill);
00052             drawBackground(g);
00053         }
00054         Color frame = getFrameColor();
00055         if (!ColorMap.getColorMap().isTransparent(frame)) {
00056             g.setColor(frame);
00057             drawFrame(g);
00058         }
00059        if (showGuides) {
00060            drawURL(g);
00061        }
00062     }
00063 
00068     protected void drawBackground(Graphics g) {
00069     }
00070 
00075     protected void drawFrame(Graphics g) {
00076     }
00077 
00082     private void drawURL(Graphics g) {
00083        String sense = (String)getAttribute("Sensitive");
00084        if (sense != null && sense.length() > 0) {
00085            Rectangle r = displayBox();
00086            g.setColor(Color.red);
00087            g.setFont(dialogFont);
00088            g.drawString("url=" + sense, r.x, r.y + r.height);
00089        }
00090     }
00091 
00097     public Color getFillColor() {
00098         return (Color) getAttribute("FillColor");
00099     }
00100 
00106     public Color getFrameColor() {
00107         return (Color) getAttribute("FrameColor");
00108     }
00109 
00110     //---- figure attributes ----------------------------------
00111 
00112     private static void initializeAttributes() {
00113         fgDefaultAttributes = new FigureAttributes();
00114         fgDefaultAttributes.set("FrameColor", Color.black);
00115         fgDefaultAttributes.set("FillColor",  new Color(0x70DB93));
00116         fgDefaultAttributes.set("TextColor",  Color.black);
00117         fgDefaultAttributes.set("ArrowMode",  new Integer(0));
00118         fgDefaultAttributes.set("FontName",  "Helvetica");
00119         fgDefaultAttributes.set("FontSize",   new Integer(12));
00120         fgDefaultAttributes.set("FontStyle",  new Integer(Font.PLAIN));
00121         fgDefaultAttributes.set("TextAlign",  "Left");
00122         fgDefaultAttributes.set("Sensitive",  "");
00123     }
00124 
00129     public static Object getDefaultAttribute(String name) {
00130         if (fgDefaultAttributes == null)
00131             initializeAttributes();
00132         return fgDefaultAttributes.get(name);
00133     }
00134 
00135     public Object defaultAttribute(String name) {
00136        return getDefaultAttribute(name);
00137     }
00138 
00139     public String getMap() {
00140        return "";
00141     }
00142 }