Package org.kite9.diagram.primitives

Examples of org.kite9.diagram.primitives.StyledText


   */
  public static Container getContainerFor(Object o, Relationship rel, InsertionInterface ii) {
    if (o == null)
      return null;

    DiagramElement within = ii.returnExisting(o);
    if (within == null) {
      // no context to place the element in, so put in the
      // diagram.
      return null;
    }
View Full Code Here


  public static NounFormat asContext(final boolean border,
      final Layout d, final Label l) {
    return new NounFormat() {
      public Connected returnElement(Container c, SimpleNoun to,
          InsertionInterface ii) {
        Label toUse = (l == null) ? (to.getLabel() == null ? null
            : new TextLine(to.getLabel())) : l;
        DiagramElement de = ii.returnContext(c, to, border ? toUse
            : null, border, d);
        if (de instanceof Connected) {
          return (Connected) de;
View Full Code Here

  public Key(String boldText, String bodyText, List<Symbol> symbols) {
    this(convert(symbols), boldText, bodyText);
  }

  public Key(List<TextLine> symbols, String boldText, String bodyText) {
    this.boldText = new StyledText(boldText);
    this.bodyText = new StyledText(bodyText);
    this.symbols = symbols;
    for (TextLine textLine : symbols) {
      textLine.setParent(this);
    }
  }
View Full Code Here

  }

 
  public Arrow(String id, String label) {
    super(id);
    this.label = new StyledText(label);
  }
View Full Code Here

    return result;
  }
 
  public Glyph(String id, String stereotype, String label,  List<TextLine> text, List<Symbol> symbols, boolean divider) {
    super(id);
    this.stereotype = new StyledText(stereotype);
    if (text!=null) {
      setText(convertText(text, divider));
    }
    if (symbols!=null) {
      this.symbols = symbols;
    }
    this.label = new StyledText(label);
  }
View Full Code Here

  }

  List<Symbol> symbols = new ArrayList<Symbol>();

  public TextLine(String id, String text) {
    this.text = new StyledText(text);
  }
View Full Code Here

  public TextLine(String id, String text) {
    this.text = new StyledText(text);
  }
 
  public TextLine(String text) {
    this.text = new StyledText(text);
  }
View Full Code Here

        public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
          return type.equals(StyledText.class);
        }

        public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
          StyledText st = (StyledText) source;
          if (st.getStyle() != null) {
            writer.addAttribute("style", st.getStyle());
          }
          writer.setValue(st.getText());
        }

        public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
          String style = reader.getAttribute("style");
          String text = reader.getValue();
          return new StyledText(text, style);
        }
      });

      // this makes it so that if the type is not specified in the xml, we
      // assume a string.
      xstream.registerConverter(new StringConverter() {

        @Override
        public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
          return super.canConvert(type) || type.equals(Object.class);
        }

      }, 10);

      // this compacts the representation of a hint map, which is
      // otherwise excessive
      xstream.registerConverter(new Converter() {

        public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
          HintMap map = (HintMap) source;
          for (Iterator<Entry<String, Float>> iterator = map.entrySet().iterator(); iterator.hasNext();) {
            Entry<String, Float> entry = iterator.next();
            writer.addAttribute(entry.getKey().toString(), entry.getValue().toString());
          }
        }

        @SuppressWarnings("unchecked")
        public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
          HintMap properties = new HintMap();
          for (Iterator iterator = reader.getAttributeNames(); iterator.hasNext();) {
            String n = (String) iterator.next();
            String v = reader.getAttribute(n);
            Float f = Float.parseFloat(v);
            properties.put(n, f);
          }

          return properties;
        }
       
        @SuppressWarnings("unchecked")
        public boolean canConvert(Class type) {
          return type == HintMap.class;
        }

      });

      // allow labels/stereotypes to appear in attributes.
      xstream.registerConverter(new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider()) {

        @Override
        public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
          return type.equals(Glyph.class) || type.equals(Arrow.class);
        }

        @Override
        public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
          String attLabel = reader.getAttribute("label");
          String attStereo = reader.getAttribute("stereotype");
          Object out = super.unmarshal(reader, context);

          if (out instanceof Glyph) {
            if (((Glyph) out).getLabel() == null) {
              ((Glyph) out).setLabel(new StyledText(attLabel));
            }

            if (((Glyph) out).getStereotype() == null) {
              ((Glyph) out).setStereotype(new StyledText(attStereo));
            }

          } else if (out instanceof Arrow) {
            if (((Arrow) out).getLabel() == null) {
              ((Arrow) out).setLabel(new StyledText(attLabel));
            }
          }

          return out;
        }
View Full Code Here

      String stepNoText = "" + stepNumber + ", ";
      if (out == null) {
        out = new TextLine(stepNoText);
      } else if (out instanceof TextLine) {
        TextLine tl = (TextLine) out;
        StyledText st = tl.getText();
        tl.setText(new StyledText(stepNoText + st.getText(), st.getStyle()));
      }
      stepNumber++;
      return out;
    } else {
      return existing;
View Full Code Here

      public DiagramElement extendTextLine(TextLine container,
          Object representing, String text) {
        DiagramElement out = representing == null ? null : contents
            .get(representing);
        if (out == null) {
          StyledText st = container.getText();
          container.setText(new StyledText(st.getText() + text, st.getStyle()));
          contents.put(representing, container);
          return container;
        }
        return out;
      }
View Full Code Here

TOP

Related Classes of org.kite9.diagram.primitives.StyledText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.