コード例 #1
0
ファイル: FigureAttributes.java プロジェクト: gulrich/HotDraw
 public static void writeColor(StorableOutput dw, String colorName, Color color) {
   if (color != null) {
     dw.writeString(colorName);
     dw.writeInt(color.getRed());
     dw.writeInt(color.getGreen());
     dw.writeInt(color.getBlue());
   }
 }
コード例 #2
0
 public void write(StorableOutput dw) {
   super.write(dw);
   dw.writeStorable(getStartConnector());
   dw.writeStorable(getEndConnector());
 }
コード例 #3
0
ファイル: ConverterFigure.java プロジェクト: smbillah/NetLogo
 @Override
 public void write(org.jhotdraw.util.StorableOutput dw) {
   super.write(dw);
   dw.writeStorable(Wrapper.wrap(converter));
 }
コード例 #4
0
ファイル: FigureAttributes.java プロジェクト: gulrich/HotDraw
  /**
   * Writes the attributes to a StorableInput. FigureAttributes store the following types directly:
   * Color, Boolean, String, Int. Other attribute types have to implement the Storable interface or
   * they have to be wrapped by an object that implements Storable.
   *
   * @see Storable
   * @see #write
   */
  public void write(StorableOutput dw) {
    dw.writeString("attributes");

    dw.writeInt(fMap.size()); // number of attributes
    Iterator<FigureAttributeConstant> iter = fMap.keySet().iterator();
    while (iter.hasNext()) {
      FigureAttributeConstant fac = iter.next();
      String attributeName = fac.getName();
      Object attributeValue = fMap.get(fac);

      dw.writeString(attributeName);

      if (attributeValue instanceof String) {
        dw.writeString("String");
        dw.writeString((String) attributeValue);
      } else if (attributeValue instanceof Color) {
        writeColor(dw, "Color", (Color) attributeValue);
      } else if (attributeValue instanceof Boolean) {
        dw.writeString("Boolean");
        if (((Boolean) attributeValue).booleanValue()) {
          dw.writeString("TRUE");
        } else {
          dw.writeString("FALSE");
        }
      } else if (attributeValue instanceof Integer) {
        dw.writeString("Int");
        dw.writeInt(((Integer) attributeValue).intValue());
      } else if (attributeValue instanceof Storable) {
        dw.writeString("Storable");
        dw.writeStorable((Storable) attributeValue);
      } else if (attributeValue instanceof javax.swing.JPopupMenu) {
        dw.writeString(Figure.POPUP_MENU);
      } else {
        System.err.println("Unknown attribute: " + attributeValue);
        dw.writeString("UNKNOWN");
      }
    }
  }