private static void formatStyle(
      final StringBuilder builder, final SimpleTextAttributes attributes) {
    final Color fgColor = attributes.getFgColor();
    final Color bgColor = attributes.getBgColor();
    final int style = attributes.getStyle();

    final int pos = builder.length();
    if (fgColor != null) {
      builder
          .append("color:#")
          .append(Integer.toString(fgColor.getRGB() & 0xFFFFFF, 16))
          .append(';');
    }
    if (bgColor != null) {
      builder
          .append("background-color:#")
          .append(Integer.toString(bgColor.getRGB() & 0xFFFFFF, 16))
          .append(';');
    }
    if ((style & SimpleTextAttributes.STYLE_BOLD) != 0) {
      builder.append("font-weight:bold;");
    }
    if ((style & SimpleTextAttributes.STYLE_ITALIC) != 0) {
      builder.append("font-style:italic;");
    }
    if ((style & SimpleTextAttributes.STYLE_UNDERLINE) != 0) {
      builder.append("text-decoration:underline;");
    } else if ((style & SimpleTextAttributes.STYLE_STRIKEOUT) != 0) {
      builder.append("text-decoration:line-through;");
    }
    if (builder.length() > pos) {
      builder.insert(pos, " style=\"");
      builder.append('"');
    }
  }
  /**
   * Creates a <CODE>java.awt.Image</CODE>. This image only contains the bars without any text.
   *
   * @param foreground the color of the bars
   * @param background the color of the background
   * @return the image
   */
  public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    String fullCode = code;
    if (generateChecksum && checksumText) fullCode = calculateChecksum(code);
    if (!startStopText) fullCode = fullCode.substring(1, fullCode.length() - 1);
    byte bars[] = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code);
    int wide = 0;
    for (int k = 0; k < bars.length; ++k) {
      wide += bars[k];
    }
    int narrow = bars.length - wide;
    int fullWidth = narrow + wide * (int) n;
    boolean print = true;
    int ptr = 0;
    int height = (int) barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
      int w = (bars[k] == 0 ? 1 : (int) n);
      int c = g;
      if (print) c = f;
      print = !print;
      for (int j = 0; j < w; ++j) pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
      System.arraycopy(pix, 0, pix, k, fullWidth);
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

    return img;
  }
  public int getRGB(double level) {

    double minLevel = this.minLevel;
    double maxLevel = this.maxLevel;
    // these next two also handle the possibility that maxLevel = minLevel
    if (level >= maxLevel) return maxColor.getRGB();
    else if (level <= minLevel) return minColor.getRGB();

    int interval = 0;
    for (int i = 1; i < levels.length; i++) { // start at 1, for level <
      // first interval it should
      // be < minLevel
      if (level <= levels[i]) {
        interval = i;
        i = levels.length; // force the for loop to halt
      }
    }
    // reevaluate min,maxLevel for this particular interval
    minLevel = levels[interval - 1];
    maxLevel = levels[interval];
    final double interpolation = (level - minLevel) / (maxLevel - minLevel);

    final int alpha =
        (int) (interpolation * (alphas[interval] - alphas[interval - 1]) + alphas[interval - 1]);

    // TODO: not right!
    final int red =
        (int) (interpolation * (reds[interval] - reds[interval - 1]) + reds[interval - 1]);
    final int green =
        (int) (interpolation * (greens[interval] - greens[interval - 1]) + greens[interval - 1]);
    final int blue =
        (int) (interpolation * (blues[interval] - blues[interval - 1]) + blues[interval - 1]);

    return (alpha << 24) | (red << 16) | (green << 8) | blue;
  }
Esempio n. 4
0
  /**
   * Creates a <CODE>java.awt.Image</CODE>. This image only contains the bars without any text.
   *
   * @param foreground the color of the bars
   * @param background the color of the background
   * @return the image
   */
  public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    java.awt.Canvas canvas = new java.awt.Canvas();

    String bCode = code;
    if (extended) bCode = getCode39Ex(code);
    if (generateChecksum) bCode += getChecksum(bCode);
    int len = bCode.length() + 2;
    int nn = (int) n;
    int fullWidth = len * (6 + 3 * nn) + (len - 1);
    byte bars[] = getBarsCode39(bCode);
    boolean print = true;
    int ptr = 0;
    int height = (int) barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
      int w = (bars[k] == 0 ? 1 : nn);
      int c = g;
      if (print) c = f;
      print = !print;
      for (int j = 0; j < w; ++j) pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
      System.arraycopy(pix, 0, pix, k, fullWidth);
    }
    java.awt.Image img =
        canvas.createImage(
            new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

    return img;
  }
Esempio n. 5
0
  public void animate() {
    // calculate gradient based on health percentage
    int gradient = 130 - (100 * p.health / p.maxHealth);

    if (animating == false) {
      animating = true;
      for (Tile[] tileRow : tiles)
        for (Tile t : tileRow) t.setBackground(new Color(gradient, 0, 0));
      return;
    }

    Color cur = tiles[0][0].getBackground();
    Color dest = new Color(0, 0, 0);

    // Calculate dif to about 20 iterations
    int dif = gradient / 20;

    if (cur.getRed() <= dest.getRed() || cur.getRed() < dif) {
      cur = dest;
      animating = false;
    }

    if (cur.getRGB() != dest.getRGB()) {
      cur = new Color(cur.getRed() - dif, cur.getGreen(), cur.getBlue());
      for (Tile[] tileRow : tiles)
        for (Tile t : tileRow) {
          t.setBackground(cur);
          Tile.setFade(
              new Color(cur.getRed(), cur.getGreen(), cur.getBlue(), Tile.getFade().getAlpha()));
        }
    }
  }
Esempio n. 6
0
 void printOnVision(Point a, Color color) {
   int tmpx = a.x;
   int tmpy = a.y;
   vision.addLine(
       new Point(tmpx - 10, tmpy - 10), new Point(tmpx + 10, tmpy + 10), color.getRGB());
   vision.addLine(
       new Point(tmpx + 10, tmpy - 10), new Point(tmpx - 10, tmpy + 10), color.getRGB());
 }
Esempio n. 7
0
  /**
   * Sets the border color to be used when the channel is selected.
   *
   * @param c The border color to be used when the channel is selected.
   */
  public static void setBorderColor(Color c) {
    if (borderColor != null && borderColor.getRGB() == c.getRGB()) return;

    Color oldColor = borderColor;
    borderColor = c;
    borderSelected = new LineBorder(getBorderColor(), 2, true);
    firePropertyChanged("borderColor", oldColor, borderColor);
  }
 @Override
 public void setBackground(Color c) {
   if (txt_box == null)
     return; // WORKAROUND.OSX: OSX LookAndFeel calls setBackground during ctor of Mem_html;
   // DATE:2015-05-11
   if (c.getRGB() == Color.BLACK.getRGB()) txt_box.setCaretColor(Color.WHITE);
   else if (c.getRGB() == Color.WHITE.getRGB()) txt_box.setCaretColor(Color.BLACK);
   super.setBackground(c);
 }
Esempio n. 9
0
 public void floodFillRecursive(int x, int y, Color target_color, Color replacement_color) {
   if (imageBuffer.getRGB(x, y) != target_color.getRGB()) {
     return;
   }
   imageBuffer.setRGB(x, y, replacement_color.getRGB());
   floodFillRecursive(x + dx[0], y + dy[0], target_color, replacement_color);
   floodFillRecursive(x + dx[1], y + dy[1], target_color, replacement_color);
   floodFillRecursive(x + dx[2], y + dy[2], target_color, replacement_color);
   floodFillRecursive(x + dx[3], y + dy[3], target_color, replacement_color);
 }
Esempio n. 10
0
  public void draw(float rect_width, float rect_height, float right_edge, float bottom_edge) {

    // parent.println(".");

    parent.textFont(parent.stack_font);
    parent.textSize(parent.new_tweets_stack_font_size);
    parent.textAlign(Twt.RIGHT);
    float z_pos = 0;
    float line_height = parent.textAscent() + parent.textDescent();
    float top_edge = bottom_edge - rect_height;
    float current_y = bottom_edge - rect_height; // bottom_edge - parent.textDescent();
    float cum_fade_out_correction = 0f;

    int fades_to_remove = 0;

    synchronized (new_tweets_stack) {
      for (int i = 0; i < new_tweets_stack.size(); i++) {
        // parent.println(i);
        float target_y =
            bottom_edge - parent.textDescent() - (float) i * (line_height * separation_factor);
        Tweet tweet = new_tweets_stack.elementAt(i);
        if (tweet.age() < IncomingStack.fade_in_time) {
          if (fade_ins.size() <= i) fade_ins.add(setUpFadein());
          parent.fill(color.getRGB(), 127 * fade_ins.elementAt(i).position());
          current_y = top_edge + (target_y - top_edge) * fade_ins.elementAt(i).position();
          // parent.println("fading in at " + current_y);
        } else if (tweet.age() > IncomingStack.display_time + IncomingStack.fade_in_time) {
          if (fade_outs.size() <= i) fade_outs.add(setUpFadeout());
          parent.fill(color.getRGB(), 127 * (1f - fade_outs.elementAt(i).position()));
          current_y =
              target_y + line_height * separation_factor * fade_outs.elementAt(i).position();
          cum_fade_out_correction +=
              line_height * separation_factor * fade_outs.elementAt(i).position();
          // parent.println("fading out at " + current_y);
          if (!fade_outs.elementAt(i).isTweening()) {
            fades_to_remove += 1;
            tweet.is_newcommer = false;
          }
        } else {
          parent.fill(color.getRGB(), color.getAlpha());
          // parent.println("showing at " + current_y);
          current_y = target_y;
        }
        // FIXME: there's a blink after a tweet is removed from the stack. Why?
        parent.text(tweet.the_tweet, right_edge, current_y + cum_fade_out_correction, z_pos);
      }

      while (fades_to_remove > 0) {
        fade_outs.removeElementAt(0);
        fade_ins.removeElementAt(0);
        new_tweets_stack.removeElementAt(0);
        fades_to_remove--;
      }
    }
  }
Esempio n. 11
0
 @Override
 public int compareTo(Object o) {
   Color col = (Color) o;
   if (col.getRGB() > color.getRGB()) {
     return -1;
   } else if (col.getRGB() == color.getRGB()) {
     return 0;
   } else {
     return 1;
   }
 }
Esempio n. 12
0
 public BufferedImage reverseImage(BufferedImage source, boolean x) {
   BufferedImage result =
       new BufferedImage(source.getWidth(), source.getHeight(), BufferedImage.TYPE_INT_ARGB);
   for (int i = 0; i < source.getWidth(); i++)
     for (int j = 0; j < source.getHeight(); j++) {
       int rgb = source.getRGB(i, j);
       Color col = new Color(rgb);
       int alpha = getAlpha(rgb);
       col = new Color(col.getRed(), col.getGreen(), col.getBlue(), alpha);
       if (x == true) result.setRGB(result.getWidth() - i - 1, j, col.getRGB());
       if (x == false) result.setRGB(i, result.getHeight() - j - 1, col.getRGB());
     }
   return result;
 }
Esempio n. 13
0
 /* Color.toString() is not great so we need a way to convert a
  * Color to some easily readable format, since we only
  * support black, white, blue, green, red, & yellow we can
  * easily check these by looking at the RGB values of the
  * color found by calling Color.getRGB().
  */
 public String colorToString(Color color) {
   if (color.getRGB() == Color.BLACK.getRGB()) {
     return "Black";
   } else if (color.getRGB() == Color.BLUE.getRGB()) {
     return "Blue";
   } else if (color.getRGB() == Color.GREEN.getRGB()) {
     return "Green";
   } else if (color.getRGB() == Color.RED.getRGB()) {
     return "Red";
   } else if (color.getRGB() == Color.YELLOW.getRGB()) {
     return "Yellow";
   } else {
     return "No Color Information";
   }
 }
Esempio n. 14
0
  public static void addLabel(final TestFrameworkRunningModel model) {
    String label;
    int color;

    if (model.getRoot().isDefect()) {
      color = RED.getRGB();
      label = ExecutionBundle.message("junit.runing.info.tests.failed.label");
    } else {
      color = GREEN.getRGB();
      label = ExecutionBundle.message("junit.runing.info.tests.passed.label");
    }
    final TestConsoleProperties consoleProperties = model.getProperties();
    String name = label + " " + consoleProperties.getConfiguration().getName();
    LocalHistory.getInstance().putSystemLabel(consoleProperties.getProject(), name, color);
  }
Esempio n. 15
0
 public String getCSVLine() {
   String csvLine = toCSVString(routeId) + ",";
   if (agencyId != null) csvLine += toCSVString(agencyId);
   csvLine += "," + toCSVString(routeShortName) + "," + toCSVString(routeLongName) + ",";
   if (routeDesc != null) csvLine += toCSVString(routeDesc);
   csvLine += "," + routeType + ",";
   if (routeURL != null) csvLine += toCSVString(routeURL.toString());
   csvLine += ",";
   if (routeColor != null)
     csvLine += Integer.toHexString(routeColor.getRGB()).toUpperCase().substring(2);
   csvLine += ",";
   if (routeTextColor != null)
     csvLine += Integer.toHexString(routeTextColor.getRGB()).toUpperCase().substring(2);
   return csvLine;
 }
  @Override
  protected void writeXMLElementInnerData(XMLStreamWriter xsw) throws XMLStreamException {

    xsw.writeEmptyElement("location"); // <location ... />
    xsw.writeAttribute("value", location);

    xsw.writeEmptyElement("address"); // <address ... />
    xsw.writeAttribute("value", address);

    xsw.writeEmptyElement("latitude"); // <latitude ... />
    xsw.writeAttribute("value", Float.toString(latitude));

    xsw.writeEmptyElement("longitude"); // <longitude ... />
    xsw.writeAttribute("value", Float.toString(longitude));

    xsw.writeEmptyElement("location_included"); // <location_included ... />
    xsw.writeAttribute("value", Boolean.toString(locationIncluded));

    xsw.writeEmptyElement("icon_included"); // <icon_included ... />
    xsw.writeAttribute("value", Boolean.toString(iconIncluded));

    xsw.writeEmptyElement("description_included"); // <description_included ... />
    xsw.writeAttribute("value", Boolean.toString(descriptionIncluded));

    xsw.writeEmptyElement("temperature_included"); // <temperature_included ... />
    xsw.writeAttribute("value", Boolean.toString(temperatureIncluded));

    xsw.writeEmptyElement("is_fahrenheit"); // <is_fahrenheit ... />
    xsw.writeAttribute("value", Boolean.toString(isFahrennheit));

    xsw.writeEmptyElement("humidity_included"); // <humidity_included ... />
    xsw.writeAttribute("value", Boolean.toString(humidityIncluded));

    xsw.writeEmptyElement("precipitation_included"); // <precipitation_included ... />
    xsw.writeAttribute("value", Boolean.toString(windSpeedIncluded));

    xsw.writeEmptyElement("forecast_included"); // <forecast_included ... />
    xsw.writeAttribute("value", Boolean.toString(forecastIncluded));

    xsw.writeEmptyElement("is_rectangular"); // <is_rectangular ... />
    xsw.writeAttribute("value", Boolean.toString(isRectangular));

    xsw.writeEmptyElement("text_color"); // <text_color ... />
    xsw.writeAttribute("value", Integer.toString(textColor.getRGB()));

    xsw.writeEmptyElement("background_color"); // <background_color ... />
    xsw.writeAttribute("value", Integer.toString(backgroundColor.getRGB()));
  }
Esempio n. 17
0
  /** Writes the attributes of the figure into the specified DOMOutput. */
  public static void writeAttributes(Figure f, DOMOutput out) throws IOException {
    Color color;
    Double dbl;
    String value;

    // Fill attributes
    color = FILL_COLOR.get(f);
    if (color == null) {
      value = "none";
    } else {
      value = "000000" + Integer.toHexString(color.getRGB());
      value = "#" + value.substring(value.length() - 6);
    }
    out.addAttribute("fill", value);
    if (WINDING_RULE.get(f) != WindingRule.NON_ZERO) {
      out.addAttribute("fill-rule", "evenodd");
    }

    // Stroke attributes
    color = STROKE_COLOR.get(f);
    if (color == null) {
      value = "none";
    } else {
      value = "000000" + Integer.toHexString(color.getRGB());
      value = "#" + value.substring(value.length() - 6);
    }
    out.addAttribute("stroke", value);
    out.addAttribute("stroke-width", STROKE_WIDTH.get(f), 1d);
    out.addAttribute(
        "stroke-miterlimit", STROKE_MITER_LIMIT_FACTOR.get(f) / STROKE_WIDTH.get(f), 4d);
    double[] dashes = STROKE_DASHES.get(f);
    dbl = (STROKE_DASH_FACTOR.get(f) == null) ? STROKE_WIDTH.get(f) : STROKE_DASH_FACTOR.get(f);
    if (dashes != null) {
      StringBuilder buf = new StringBuilder();
      for (int i = 0; i < dashes.length; i++) {
        if (i != 0) {
          buf.append(',');
          buf.append(dashes[i] * dbl);
        }
        out.addAttribute("stroke-dasharray", buf.toString());
      }
    }
    out.addAttribute("stroke-dashoffset", STROKE_DASH_PHASE.get(f), 0d);

    // Text attributes
    out.addAttribute("font-size", FONT_SIZE.get(f));
    // out.addAttribute("text-anchor", "start");
  }
Esempio n. 18
0
    @Override
    public int getColor(VisualItem item) {

      // get value for target attr in item
      if (item.canGetString(colorAttrName)) {
        String attrVal = item.getString(colorAttrName);
        Color attrValColor = catToColorMap.get(attrVal);
        if (attrValColor == null) {
          return Color.CYAN.getRGB();
        }
        return attrValColor.getRGB();
      }

      Color white = Color.WHITE;
      return white.getRGB();
    }
Esempio n. 19
0
 /**
  * Internal method to convert a AWT color object into a SWT color resource. If a corresponding SWT
  * color instance is already in the pool, it will be used instead of creating a new one. This is
  * used in {@link #setColor()} for instance.
  *
  * @param awtColor The AWT color to convert.
  * @return A SWT color instance.
  */
 private org.eclipse.swt.graphics.Color getSwtColorFromPool(Color awtColor) {
   org.eclipse.swt.graphics.Color swtColor =
       (org.eclipse.swt.graphics.Color)
           // we can't use the following valueOf() method, because it
           // won't compile with JDK1.4
           // this.colorsPool.get(Integer.valueOf(awtColor.getRGB()));
           this.colorsPool.get(new Integer(awtColor.getRGB()));
   if (swtColor == null) {
     swtColor = SWTUtils.toSwtColor(this.gc.getDevice(), awtColor);
     addToResourcePool(swtColor);
     // see comment above
     // this.colorsPool.put(Integer.valueOf(awtColor.getRGB()), swtColor);
     this.colorsPool.put(new Integer(awtColor.getRGB()), swtColor);
   }
   return swtColor;
 }
Esempio n. 20
0
  /**
   * Creates a tileset from a tileset image file.
   *
   * @param imgFilename
   * @param cutter
   * @throws IOException
   * @see TileSet#importTileBitmap(BufferedImage, TileCutter)
   */
  public void importTileBitmap(String imgFilename, TileCutter cutter) throws IOException {
    setTilesetImageFilename(imgFilename);

    File f = new File(imgFilename);

    Image image = ImageIO.read(f.getCanonicalFile());
    if (image == null) {
      throw new IOException("Failed to load " + tilebmpFile);
    }

    Toolkit tk = Toolkit.getDefaultToolkit();

    if (transparentColor != null) {
      int rgb = transparentColor.getRGB();
      image =
          tk.createImage(
              new FilteredImageSource(image.getSource(), new TransparentImageFilter(rgb)));
    }

    BufferedImage buffered =
        new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    buffered.getGraphics().drawImage(image, 0, 0, null);

    importTileBitmap(buffered, cutter);
  }
Esempio n. 21
0
    /**
     * DOCUMENT ME!
     *
     * @param c DOCUMENT ME!
     * @return DOCUMENT ME!
     */
    private Color unwrap(Color c) {
      if (c instanceof UIResource) {
        return new Color(c.getRGB());
      }

      return c;
    }
Esempio n. 22
0
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
      Element info = new Element(INFO_TAG);
      String severityName = severity.getName();
      final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
      if (infoType != null) {
        infoType.writeExternal(info);
        final Color color = myRendererColors.get(severityName);
        if (color != null) {
          info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
        }
        element.addContent(info);
      }
    }

    if (myReadOrder != null && !myReadOrder.isEmpty()) {
      myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
      final JDOMExternalizableStringList ext =
          new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
      getOrderMap()
          .forEachEntry(
              new TObjectIntProcedure<HighlightSeverity>() {
                @Override
                public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                  ext.set(oIdx, orderSeverity.getName());
                  return true;
                }
              });
      ext.writeExternal(element);
    }
  }
Esempio n. 23
0
  /** Redraws the image. */
  private void redrawImage() {
    ScreenToWorldPointConverter converter = null;
    try {
      converter =
          new ScreenToWorldPointConverter(
              currWXMin, currWYMin, currWXMax, currWYMax, 0, 0, width - 1, height - 1);
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }

    Point2D P = null;
    Point2D.Double screenPoint = new Point2D.Double();
    ComplexNumber C = null;
    Color theColor = null;
    int colorIndex = 0;
    for (int i = 0; i < width; ++i) {
      for (int j = 0; j < height; ++j) {
        screenPoint.setLocation(i, j);
        P = converter.getWorldCoordinates(screenPoint);
        C = new ComplexNumber(new RealNumber(P.getX()), new RealNumber(P.getY()));
        colorIndex = Mandelbrot.divergenceIndex(C);
        if (colorIndex < 0) {
          theColor = Color.black;
        } else {
          theColor = Mandelbrot.getColor(colorIndex);
        }
        img.paintPixel(i, j, theColor.getRGB());
      }
    }
  }
  protected void exportFrame(
      TableBuilder tableBuilder, JRPrintFrame frame, JRExporterGridCell gridCell)
      throws IOException, JRException {
    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    boolean appendBackcolor =
        frame.getModeValue() == ModeEnum.OPAQUE
            && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB());

    if (appendBackcolor) {
      setBackcolor(frame.getBackcolor());
    }

    try {
      JRGridLayout layout = gridCell.getLayout();
      JRPrintElementIndex frameIndex =
          new JRPrintElementIndex(reportIndex, pageIndex, gridCell.getWrapper().getAddress());
      exportGrid(layout, frameIndex);
    } finally {
      if (appendBackcolor) {
        restoreBackcolor();
      }
    }

    tableBuilder.buildCellFooter();
  }
Esempio n. 25
0
  /**
   * Draw labels for picking.
   *
   * @param dc Current draw context.
   * @param pickSupport the PickSupport instance to be used.
   */
  protected void doPick(DrawContext dc, PickSupport pickSupport) {
    GL gl = dc.getGL();

    Angle heading = this.rotation;

    double headingDegrees;
    if (heading != null) headingDegrees = heading.degrees;
    else headingDegrees = 0;

    int x = this.screenPoint.x;
    int y = this.screenPoint.y;

    boolean matrixPushed = false;
    try {
      if (headingDegrees != 0) {
        gl.glPushMatrix();
        matrixPushed = true;

        gl.glTranslated(x, y, 0);
        gl.glRotated(headingDegrees, 0, 0, 1);
        gl.glTranslated(-x, -y, 0);
      }

      for (int i = 0; i < this.lines.length; i++) {
        Rectangle2D bounds = this.lineBounds[i];
        double width = bounds.getWidth();
        double height = bounds.getHeight();

        x = this.screenPoint.x;
        if (this.textAlign.equals(AVKey.CENTER)) x = x - (int) (width / 2.0);
        else if (this.textAlign.equals(AVKey.RIGHT)) x = x - (int) width;
        y -= this.lineHeight;

        Color color = dc.getUniquePickColor();
        int colorCode = color.getRGB();
        PickedObject po = new PickedObject(colorCode, this.getPickedObject(), this.position, false);
        pickSupport.addPickableObject(po);

        // Draw line rectangle
        gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());

        try {
          gl.glBegin(GL.GL_POLYGON);
          gl.glVertex3d(x, y, 0);
          gl.glVertex3d(x + width - 1, y, 0);
          gl.glVertex3d(x + width - 1, y + height - 1, 0);
          gl.glVertex3d(x, y + height - 1, 0);
          gl.glVertex3d(x, y, 0);
        } finally {
          gl.glEnd();
        }

        y -= this.lineSpacing;
      }
    } finally {
      if (matrixPushed) {
        gl.glPopMatrix();
      }
    }
  }
Esempio n. 26
0
  public static void main(String[] args) {
    int x = 500, y = 80;
    DrawingKit dk = new DrawingKit("Daffodils", 800, 800);
    BufferedImage pict = dk.loadPicture("daffodils.jpg");

    // get pixel value at location (500, 80)
    int encodedPixelColor = pict.getRGB(x, y);
    Color pixelColor = new Color(encodedPixelColor);
    System.out.println(pixelColor);
    int red = pixelColor.getRed();
    int green = pixelColor.getGreen();
    int blue = pixelColor.getBlue();
    // change the color of the pixel to be pure red
    red = 255;
    green = 0;
    blue = 0;

    // update the pixel color in picture
    Color newPixelColor = new Color(red, green, blue);
    int newRgbvalue = newPixelColor.getRGB();
    pict.setRGB(x, y, newRgbvalue);
    // display the approximate location of the pixel
    dk.drawPicture(pict, 0, 0);
    BasicStroke s = new BasicStroke(3);
    dk.setStroke(s);
    Ellipse2D.Float e = new Ellipse2D.Float(x - 3, y - 3, 8, 8);
    dk.draw(e);
    dk.drawString("(600, 150)", x - 3, y - 5);
  }
 @Override
 public void marshal(
     Object o, HierarchicalStreamWriter writer, MarshallingContext marshallingContext) {
   Color color = (Color) o;
   writer.setValue(String.valueOf(color.getRGB()));
   writer.endNode();
 }
  private static void assertThemeUsed(ActionBarIconGenerator.Theme theme, @Nullable Color color)
      throws Exception {
    ArgumentCaptor<ActionBarIconGenerator.ActionBarOptions> argument =
        ArgumentCaptor.forClass(ActionBarIconGenerator.ActionBarOptions.class);

    ActionBarIconGenerator generator = mock(ActionBarIconGenerator.class);

    TemplateWizardState state = new TemplateWizardState();
    AssetStudioAssetGenerator studioGenerator =
        new AssetStudioAssetGenerator(
            new TemplateWizardContextAdapter(state), generator, null, null);
    pickImage(state);
    state.put(ATTR_ASSET_TYPE, AssetType.ACTIONBAR.name());
    state.put(ATTR_ASSET_THEME, theme.name());
    state.put(ATTR_FOREGROUND_COLOR, color);
    studioGenerator.generateImages(true);

    verify(generator, times(1))
        .generate(
            isNull(String.class),
            any(Map.class),
            eq(studioGenerator),
            argument.capture(),
            anyString());

    assertEquals(theme, argument.getValue().theme);

    if (color != null && theme.equals(ActionBarIconGenerator.Theme.CUSTOM)) {
      assertEquals(color.getRGB(), argument.getValue().customThemeColor);
    }
  }
Esempio n. 29
0
  /** @param args */
  public static void main(String[] args) {
    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(null);
    File file = chooser.getSelectedFile();
    String indir = file.getAbsolutePath();
    BufferedImage out = null;
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      out = new BufferedImage(256, 1, BufferedImage.TYPE_INT_RGB);
      String sCurrentLine;
      int pos = 0;
      while ((sCurrentLine = br.readLine()) != null) {
        String[] values = sCurrentLine.split(" ");
        Color ocol =
            new Color(
                Integer.valueOf(values[0]), Integer.valueOf(values[1]), Integer.valueOf(values[2]));
        out.setRGB(pos, 0, ocol.getRGB());
        pos++;
      }
      File outputimage = new File("C:\\ydkj\\palette", "GENPALETTE.bmp");
      ImageIO.write(out, "bmp", outputimage);

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  private void setSubscriberDetails(
      String subscriberName, String subscriberAddress, String message) {
    this.name = subscriberName;
    this.address = subscriberAddress;

    Color color = messagePane.getForeground();

    messagePane.setText(
        "<FONT COLOR=\"#"
            + Integer.toHexString(color.getRGB()).substring(2)
            + "\">"
            + messageString1
            + "<p>"
            + namePrefix
            + name
            + nameSuffix
            + "<br>"
            + addressPrefix
            + address
            + addressSuffix
            + "<p>"
            + ((message != null && message.trim().length() > 0)
                ? messagePrefix + message + messageSuffix + "<p>"
                : "")
            + messageString2
            + "</FONT>");
  }