Ejemplo n.º 1
0
  private void addParameter(String name, String value) {
    if (value != null) value = value.trim();
    if (name.equals("stroke")) {
      if (value != null && value.length() > 0) {
        Color c = Color.getColor(value);
        if (c == null) {
          if (value.charAt(0) == '#') value = value.substring(1);
          int ci = Integer.parseInt(value, 16);
          c = new Color(ci);
        }

        if (c != null) {
          Material material = app.getMaterial();
          if (material == null) material = new Material();
          material.setDiffuseColor(c.getRGBComponents(null));
          material.setLightingEnabled(false);
          // material.setColorMaterialEnabled(true);
          // material.setSeparateBackfaceEnabled(true);
          app.setMaterial(material);
        }
      }
    } else if (name.equals("stroke-width")) {
      float width = Float.parseFloat(value);
      LineAttributes l_att = app.getLineAttributes();
      if (l_att == null) l_att = new LineAttributes();
      l_att.setLineWidth(width);
      app.setLineAttributes(l_att);
    }
  }
Ejemplo n.º 2
0
  protected java.awt.Color modulateColorOpacity(java.awt.Color color, double opacity) {
    float[] compArray = new float[4];
    color.getRGBComponents(compArray);
    compArray[3] *= (float) opacity;

    return new java.awt.Color(compArray[0], compArray[1], compArray[2], compArray[3]);
  }
Ejemplo n.º 3
0
 /**
  * Places the RGBA values from the given Color object into the destination array.
  *
  * @param color the color to convert
  * @param destination the array to hold the RGBA values; length 4
  */
 public static final void convertColor(Color color, float[] destination) {
   color.getRGBComponents(destination);
 }
Ejemplo n.º 4
0
 /**
  * Returns an array of color components for the given Color object.
  *
  * @param color the color object
  * @return float[]
  */
 public static final float[] convertColor(Color color) {
   return color.getRGBComponents(null);
 }