Example #1
0
  /**
   * Esta funcion se usa para inicializar los colores del tema segun los argumentos que se le pasen.
   */
  static NimRODTheme iniCustomColors(
      NimRODTheme nt,
      String selection,
      String background,
      String p1,
      String p2,
      String p3,
      String s1,
      String s2,
      String s3,
      String w,
      String b,
      String opMenu,
      String opFrame) {
    if (selection != null) {
      nt.setPrimary(Color.decode(selection));
    }
    if (background != null) {
      nt.setSecondary(Color.decode(background));
    }

    if (p1 != null) {
      nt.setPrimary1(Color.decode(p1));
    }
    if (p2 != null) {
      nt.setPrimary2(Color.decode(p2));
    }
    if (p3 != null) {
      nt.setPrimary3(Color.decode(p3));
    }

    if (s1 != null) {
      nt.setSecondary1(Color.decode(s1));
    }
    if (s2 != null) {
      nt.setSecondary2(Color.decode(s2));
    }
    if (s3 != null) {
      nt.setSecondary3(Color.decode(s3));
    }

    if (w != null) {
      nt.setWhite(Color.decode(w));
    }
    if (b != null) {
      nt.setBlack(Color.decode(b));
    }

    if (opMenu != null) {
      nt.setMenuOpacity(Integer.parseInt(opMenu));
    }
    if (opFrame != null) {
      nt.setFrameOpacity(Integer.parseInt(opFrame));
    }

    return nt;
  }
  /**
   * WhiteboardObjectTextJabberImpl constructor.
   *
   * @param xml the XML string object to parse.
   */
  public WhiteboardObjectTextJabberImpl(String xml) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    try {
      builder = factory.newDocumentBuilder();
      InputStream in = new ByteArrayInputStream(xml.getBytes());
      Document doc = builder.parse(in);

      Element e = doc.getDocumentElement();
      String elementName = e.getNodeName();
      if (elementName.equals("text")) {
        // we have a text
        String id = e.getAttribute("id");
        double x = Double.parseDouble(e.getAttribute("x"));
        double y = Double.parseDouble(e.getAttribute("y"));
        String fill = e.getAttribute("fill");
        String fontFamily = e.getAttribute("font-family");
        int fontSize = Integer.parseInt(e.getAttribute("font-size"));
        String text = e.getTextContent();

        this.setID(id);
        this.setWhiteboardPoint(new WhiteboardPoint(x, y));
        this.setFontName(fontFamily);
        this.setFontSize(fontSize);
        this.setText(text);
        this.setColor(Color.decode(fill).getRGB());
      }
    } catch (ParserConfigurationException ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    } catch (IOException ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    } catch (Exception ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    }
  }
Example #3
0
 // convert color name in Java Color object
 public Color getColour(String name) {
   if (name.equals("red")) {
     return Color.red;
   } else if (name.equals("blue")) {
     return Color.blue;
   } else if (name.equals("black")) {
     return Color.black;
   } else if (name.equals("cyan")) {
     return Color.cyan;
   } else if (name.equals("dark gray")) {
     return Color.darkGray;
   } else if (name.equals("gray")) {
     return Color.gray;
   } else if (name.equals("light gray")) {
     return Color.lightGray;
   } else if (name.equals("green")) {
     return Color.gray;
   } else if (name.equals("magenta")) {
     return Color.magenta;
   } else if (name.equals("orange")) {
     return Color.orange;
   } else if (name.equals("pink")) {
     return Color.pink;
   } else if (name.equals("white")) {
     return Color.white;
   } else if (name.equals("yellow")) {
     return Color.yellow;
   }
   try {
     // see if the colour is expressed in
     // 0xAABBCC format for RGB...
     return Color.decode(name);
   } catch (NumberFormatException e) {
   }
   // no, ok bail then ... but this will certainly
   // through an exception
   return null;
 }
Example #4
0
  /**
   * Parses a text file and creates an Obj3d. The file format is as follows:
   *
   * <pre>
   *
   * # a simple kite made of two triangular polygons
   * # by foo bar, 27 Aug 2002
   * 2
   * t f CC99FF 12.1 2.4 3.5, 12.4 2.2 3.5, 3.2 5 7.4,
   * t t 336699 9.7 0 3.5, 2.2 2.2 3.5, 3.2 5 7.3,
   *
   * </pre>
   *
   * The above represents an Obj3d with two polygons, the second of which is double sided; each is a
   * differnt color; each is made up of 3 points. Both cast shadows. The first flag indicates if the
   * polygon casts a shadow. The second flag indicates if the polygon is double sided.
   */
  public Obj3d(StreamTokenizer st, ModelViewer modelViewer, boolean register)
      throws IOException, FileFormatException {

    // call to constructor must be first, but we do not
    // know how many polygons yet, hence the following
    this(modelViewer, register);

    // gobble EOL's due to comments
    while (st.nextToken() == StreamTokenizer.TT_EOL) {;
    }

    // how many polygons
    int num = (int) st.nval;

    // set num polygons
    this.setNumPolygons(num);

    // gobble up new line
    st.nextToken();

    // Tools3d.debugTokens(st); //tmp
    // System.exit(0);

    // read a line a data for each polygon
    for (int i = 0; i < num; i++) {

      // has shadow ?
      st.nextToken();
      boolean shadow = "t".equals(st.sval);

      // double sided ?
      st.nextToken();
      boolean doubleSided = "t".equals(st.sval);

      // color - a hex number
      Color color = null;
      st.nextToken();
      try {
        color = Color.decode("0x" + st.sval);
      } catch (NumberFormatException e) {
        throw new FileFormatException(
            "Unable to parse color: " + st.sval + ", polygon index: " + i);
      }

      if (color == null) {
        color = COLOR_DEFAULT;
      }

      // read point co-ords until we reach end of line
      Vector points = new Vector();
      while (st.nextToken() != StreamTokenizer.TT_EOL) {

        float[] p = new float[3];

        p[0] = (float) st.nval;
        st.nextToken();
        p[1] = (float) st.nval;
        st.nextToken();
        p[2] = (float) st.nval;

        // gobble up comma which seperates points
        // note there must be a comma after the last point
        if (st.nextToken() != ',') {
          throw new FileFormatException("Unable to parse co-ordinates; comma expected: " + st);
        }
        points.addElement(p);
      }

      // convert vector to an array
      float[][] vs = new float[points.size()][];
      for (int j = 0; j < points.size(); j++) {
        vs[j] = (float[]) points.elementAt(j);
      }

      // finally, add the polygon
      if (!shadow) {
        this.addPolygon(vs, color, doubleSided);
      } else {
        this.addPolygonWithShadow(vs, color, doubleSided);
      }
    }
  }