Ejemplo n.º 1
1
 /**
  * Event.detail line start offset (input) Event.text line text (input) LineStyleEvent.styles
  * Enumeration of StyleRanges, need to be in order. (output) LineStyleEvent.background line
  * background color (output)
  */
 public void lineGetStyle(LineStyleEvent event) {
   Vector styles = new Vector();
   int token;
   StyleRange lastStyle;
   // If the line is part of a block comment, create one style for the entire line.
   if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) {
     styles.addElement(
         new StyleRange(event.lineOffset, event.lineText.length(), getColor(COMMENT), null));
     event.styles = new StyleRange[styles.size()];
     styles.copyInto(event.styles);
     return;
   }
   Color defaultFgColor = ((Control) event.widget).getForeground();
   scanner.setRange(event.lineText);
   token = scanner.nextToken();
   while (token != EOF) {
     if (token == OTHER) {
       // do nothing for non-colored tokens
     } else if (token != WHITE) {
       Color color = getColor(token);
       // Only create a style if the token color is different than the
       // widget's default foreground color and the token's style is not
       // bold.  Keywords are bolded.
       if ((!color.equals(defaultFgColor)) || (token == KEY)) {
         StyleRange style =
             new StyleRange(
                 scanner.getStartOffset() + event.lineOffset, scanner.getLength(), color, null);
         if (token == KEY) {
           style.fontStyle = SWT.BOLD;
         }
         if (styles.isEmpty()) {
           styles.addElement(style);
         } else {
           // Merge similar styles.  Doing so will improve performance.
           lastStyle = (StyleRange) styles.lastElement();
           if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) {
             lastStyle.length += style.length;
           } else {
             styles.addElement(style);
           }
         }
       }
     } else if ((!styles.isEmpty())
         && ((lastStyle = (StyleRange) styles.lastElement()).fontStyle == SWT.BOLD)) {
       int start = scanner.getStartOffset() + event.lineOffset;
       lastStyle = (StyleRange) styles.lastElement();
       // A font style of SWT.BOLD implies that the last style
       // represents a java keyword.
       if (lastStyle.start + lastStyle.length == start) {
         // Have the white space take on the style before it to
         // minimize the number of style ranges created and the
         // number of font style changes during rendering.
         lastStyle.length += scanner.getLength();
       }
     }
     token = scanner.nextToken();
   }
   event.styles = new StyleRange[styles.size()];
   styles.copyInto(event.styles);
 }
  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>");
  }
Ejemplo n.º 3
0
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Ejemplo n.º 4
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);
    }
  }
Ejemplo n.º 5
0
 /** Patches attributes to be visible under debugger active line */
 @SuppressWarnings("UseJBColor")
 public static TextAttributes patchAttributesColor(
     TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) {
   if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null)
     return attributes;
   MarkupModel model =
       DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
   if (model != null) {
     if (!((MarkupModelEx) model)
         .processRangeHighlightersOverlappingWith(
             range.getStartOffset(),
             range.getEndOffset(),
             highlighter -> {
               if (highlighter.isValid()
                   && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
                 TextAttributes textAttributes = highlighter.getTextAttributes();
                 if (textAttributes != null) {
                   Color color = textAttributes.getBackgroundColor();
                   return !(color != null
                       && color.getBlue() > 128
                       && color.getRed() < 128
                       && color.getGreen() < 128);
                 }
               }
               return true;
             })) {
       TextAttributes clone = attributes.clone();
       clone.setForegroundColor(Color.orange);
       clone.setEffectColor(Color.orange);
       return clone;
     }
   }
   return attributes;
 }
Ejemplo n.º 6
0
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
Ejemplo n.º 7
0
 public Star(Point loc, Color c, int alpha) {
   location = loc;
   r = c.getRed();
   b = c.getBlue();
   g = c.getGreen();
   a = alpha;
   pulseRate = rand.nextInt(155);
 }
Ejemplo n.º 8
0
 /**
  * Sets the fillColor and defines the outline color to be a non-transparent version of the fill
  * color
  */
 public void setColor(Color fillColor) {
   m_fillColor = fillColor;
   m_outlineColor =
       new Color(
           fillColor.getRed() < 255 ? 0.0f : 1.0f,
           fillColor.getGreen() < 255 ? 0.0f : 1.0f,
           fillColor.getBlue() < 255 ? 0.0f : 1.0f);
 }
Ejemplo n.º 9
0
  // TODO how to calculate minimum-difference pixels?
  @Override
  protected void changeQueue(Pixel p) {
    // recalculate neighbors
    for (Pixel np : p.neighbors) {
      if (np.isEmpty) {
        int r = 0, g = 0, b = 0, n = 0;
        for (Pixel nnp : np.neighbors) {
          if (!nnp.isEmpty) {
            r += nnp.color.getRed();
            g += nnp.color.getGreen();
            b += nnp.color.getBlue();
            n++;
          }
        }

        np.nonEmptyNeigh++;

        r /= n;
        g /= n;
        b /= n;

        Color avg = new Color(r, g, b);

        Color newBlock =
            new Color(
                r >> blockOffset & blockMask,
                g >> blockOffset & blockMask,
                b >> blockOffset & blockMask);
        int blockIndex =
            newBlock.getRed() * rOffset
                + newBlock.getGreen() * gOffset
                + newBlock.getBlue() * bOffset;

        if (!np.inQueue) {
          np.block = blockIndex;
          np.inQueue = true;
          pixelBlocks[blockIndex].add(np);
        } else if (blockIndex != np.block) {
          if (!pixelBlocks[np.block].remove(np)) {
            System.out.println(
                "Couldn't remove pixel "
                    + np
                    + ", even though it should be in block "
                    + blockIndex
                    + " !");
          }

          np.inQueue = true;
          np.block = blockIndex;
          pixelBlocks[blockIndex].add(np);
        }

        np.avg = avg;
      }
    }
  }
Ejemplo n.º 10
0
 /**
  * Turn a (possibly) translucent or indexed image into a display-compatible bitmask image using
  * the given alpha threshold and render-to-background colour, or display-compatible translucent
  * image. The alpha values in the image are set to either 0 (below threshold) or 255 (above
  * threshold). The render-to-background colour bg_col is used to determine how the pixels
  * overlapping transparent pixels should be rendered. The fast algorithm just sets the colour
  * behind the transparent pixels in the image (for bitmask source images); the slow algorithm
  * actually renders the image to a background of bg_col (for translucent sources).
  *
  * @param thresh alpha threshold between 0 and 255
  * @param fast use fast algorithm (only set bg_col behind transp. pixels)
  * @param bitmask true=use bitmask, false=use translucent
  */
 public JGImage toDisplayCompatible(int thresh, JGColor bg_col, boolean fast, boolean bitmask) {
   Color bgcol = new Color(bg_col.r, bg_col.g, bg_col.b);
   int bgcol_rgb = (bgcol.getRed() << 16) | (bgcol.getGreen() << 8) | bgcol.getBlue();
   JGPoint size = getSize();
   int[] buffer = getPixels();
   // render image to bg depending on bgcol
   BufferedImage img_bg;
   if (bitmask) {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.BITMASK);
   } else {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.TRANSLUCENT);
   }
   int[] bg_buf;
   if (!fast) {
     Graphics g = img_bg.getGraphics();
     g.setColor(bgcol);
     // the docs say I could use bgcol in the drawImage as an
     // equivalent to the following two lines, but this
     // doesn't handle translucency properly and is _slower_
     g.fillRect(0, 0, size.x, size.y);
     g.drawImage(img, 0, 0, null);
     bg_buf = new JREImage(img_bg).getPixels();
   } else {
     bg_buf = buffer;
   }
   // g.dispose();
   // ColorModel rgb_bitmask = ColorModel.getRGBdefault();
   // rgb_bitmask = new PackedColorModel(
   //		rgb_bitmask.getColorSpace(),25,0xff0000,0x00ff00,0x0000ff,
   //		0x1000000, false, Transparency.BITMASK, DataBuffer.TYPE_INT);
   //		ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean
   // isAlphaPremultiplied, int trans, int transferType)
   int[] thrsbuf = new int[size.x * size.y];
   for (int y = 0; y < size.y; y++) {
     for (int x = 0; x < size.x; x++) {
       if (((buffer[y * size.x + x] >> 24) & 0xff) >= thresh) {
         thrsbuf[y * size.x + x] = bg_buf[y * size.x + x] | (0xff << 24);
       } else {
         // explicitly set the colour of the transparent pixel.
         // This makes a difference when scaling!
         // thrsbuf[y*size.x+x]=bg_buf[y*size.x+x]&~(0xff<<24);
         thrsbuf[y * size.x + x] = bgcol_rgb;
       }
     }
   }
   return new JREImage(
       output_comp.createImage(
           new MemoryImageSource(
               size.x,
               size.y,
               // rgb_bitmask,
               img_bg.getColorModel(), // display compatible bitmask
               bitmask ? thrsbuf : bg_buf,
               0,
               size.x)));
 }
Ejemplo n.º 11
0
 public Text renderwrap(String text, Color c, int width) {
   if (wfnd == null) wfnd = new RichText.Foundry(font, defcol);
   wfnd.aa = aa;
   text = RichText.Parser.quote(text);
   if (c != null)
     text =
         String.format(
             "$col[%d,%d,%d,%d]{%s}", c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha(), text);
   return (wfnd.render(text, width));
 }
Ejemplo n.º 12
0
  // 그리기
  void Draw(Canvas canvas) {
    Paint pnt = new Paint();
    pnt.setAntiAlias(true);

    int r;
    int alpha;

    for (r = rad, alpha = 1; r > 4; r--, alpha += 5) {
      pnt.setColor(Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)));
      canvas.drawCircle(x, y, r, pnt);
    }
  }
Ejemplo n.º 13
0
  public ObsBall(int x, int y, int Rad, int sideDiff, int type) {
    this.x = x;
    this.y = y;
    this.rad = Rad;
    this.sideDiff = sideDiff;
    this.type = type;

    // hero 위치에 이만큼을 더해서, 그 범위 내에서는 장애물 생성 안되게 막으려고
    offsetFromHero = Rad * 25;

    // 속도 조절
    speed[0] = MainActivity.unitSpeed * 4;
    speed[1] = (int) (MainActivity.unitSpeed * 8);
    speed[2] = (int) (MainActivity.unitSpeed * 12);

    idx_speed = 0;

    // vx 정하기.
    vx = speed[idx_speed];
    vy = speed[idx_speed];

    if (Rnd.nextInt(1) == 0) vx *= -1;
    if (Rnd.nextInt(1) == 0) vy *= -1;
    //

    inCirclePnt = new Paint();
    inCirclePnt.setAntiAlias(true);
    if (type == TYPE_OBSTACLE) { // 장애물 볼
      red[0] = 135;
      green[0] = 206;
      blue[0] = 235;
      red[1] = 28;
      green[1] = 160;
      blue[1] = 217;
      red[2] = 16;
      green[2] = 94;
      blue[2] = 126;
      inCirclePnt.setColor(Color.rgb(red[idx_color], green[idx_color], blue[idx_color]));

    } else if (type == TYPE_ENERGY) { // 노란색 볼
      inCirclePnt.setColor(Color.rgb(243, 218, 150));

    } else if (type == ICE_OBSTACLE) { // 얼음 볼
      inCirclePnt.setColor(Color.WHITE);
    }

    outCirclePnt = new Paint();
    outCirclePnt.setAntiAlias(true);
    outCirclePnt.setColor(Color.BLACK);
    outCirclePnt.setStyle(Paint.Style.STROKE);
    outCirclePnt.setStrokeWidth(rad / 5);
  }
Ejemplo n.º 14
0
 // Overridden for performance reasons. ---->
 @Override
 public boolean isOpaque() {
   Color back = getBackground();
   Component p = getParent();
   if (Objects.nonNull(p)) {
     p = p.getParent();
   } // p should now be the JTable.
   boolean colorMatch =
       Objects.nonNull(back)
           && Objects.nonNull(p)
           && back.equals(p.getBackground())
           && p.isOpaque();
   return !colorMatch && super.isOpaque();
 }
Ejemplo n.º 15
0
  /**
   * Sets the selected color of this panel.
   *
   * <p>If this panel is in RED, GREEN, or BLUE mode, then this method converts these values to RGB
   * coordinates and calls <code>setRGB</code>.
   *
   * <p>This method may regenerate the graphic if necessary.
   *
   * @param h the hue value of the selected color.
   * @param s the saturation value of the selected color.
   * @param b the brightness value of the selected color.
   */
  public void setHSB(float h, float s, float b) {
    if (Float.isInfinite(h) || Float.isNaN(h))
      throw new IllegalArgumentException("The hue value (" + h + ") is not a valid number.");
    // hue is cyclic, so it can be any value:
    while (h < 0) h++;
    while (h > 1) h--;

    if (s < 0 || s > 1)
      throw new IllegalArgumentException("The saturation value (" + s + ") must be between [0,1]");
    if (b < 0 || b > 1)
      throw new IllegalArgumentException("The brightness value (" + b + ") must be between [0,1]");

    if (hue != h || sat != s || bri != b) {
      if (mode == ColorPicker.HUE || mode == ColorPicker.BRI || mode == ColorPicker.SAT) {
        float lastHue = hue;
        float lastBri = bri;
        float lastSat = sat;
        hue = h;
        sat = s;
        bri = b;
        if (mode == ColorPicker.HUE) {
          if (lastHue != hue) {
            regenerateImage();
          }
        } else if (mode == ColorPicker.SAT) {
          if (lastSat != sat) {
            regenerateImage();
          }
        } else if (mode == ColorPicker.BRI) {
          if (lastBri != bri) {
            regenerateImage();
          }
        }
      } else {

        Color c = new Color(Color.HSBtoRGB(h, s, b));
        setRGB(c.getRed(), c.getGreen(), c.getBlue());
        return;
      }

      Color c = new Color(Color.HSBtoRGB(hue, sat, bri));
      red = c.getRed();
      green = c.getGreen();
      blue = c.getBlue();

      regeneratePoint();
      repaint();
      fireChangeListeners();
    }
  }
 public final void setModulationColor(final Color modulationColor) {
   if (modulationColor == this.m_modulationColor) {
     return;
   }
   if (modulationColor != null) {
     this.m_entity3D.setColor(
         modulationColor.getRed(),
         modulationColor.getGreen(),
         modulationColor.getBlue(),
         modulationColor.getAlpha());
   } else {
     this.m_entity3D.setColor(1.0f, 1.0f, 1.0f, 1.0f);
   }
   this.m_modulationColor = modulationColor;
 }
  private void writeColors(Element colorElements) {
    List<ColorKey> list = new ArrayList<ColorKey>(myColorsMap.keySet());
    Collections.sort(list);

    for (ColorKey key : list) {
      if (haveToWrite(key)) {
        Color value = myColorsMap.get(key);
        Element element = new Element(OPTION_ELEMENT);
        element.setAttribute(NAME_ATTR, key.getExternalName());
        element.setAttribute(
            VALUE_ELEMENT, value != null ? Integer.toString(value.getRGB() & 0xFFFFFF, 16) : "");
        colorElements.addContent(element);
      }
    }
  }
  private static String toHex(@NotNull final Color color) {
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 3; i++) {
      String s =
          Integer.toHexString(
              i == 0 ? color.getRed() : i == 1 ? color.getGreen() : color.getBlue());
      if (s.length() < 2) {
        sb.append('0');
      }

      sb.append(s);
    }

    return sb.toString();
  }
Ejemplo n.º 19
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();
    }
Ejemplo n.º 20
0
 /* Wraps everything into a Cell Manager Class*/
 private CellManager toCellManager(ImagePlus imp, ArrayList<PolygonRoi> rois, ImagePlus av_imp) {
   CellManager cm = new CellManager(av_imp, imp, this.ovr);
   Iterator itr = rois.iterator();
   ArrayList<Double> av_sig = new ArrayList<>();
   PolygonRoi roi;
   while (itr.hasNext()) {
     roi = (PolygonRoi) itr.next();
     av_sig = Activity_Analysis.getAverageSignal(imp, roi);
     CalciumSignal ca_sig = new CalciumSignal(av_sig, this.dt_r);
     ovr.add(roi);
     ca_sig.DeltaF();
     cm.addCell(ca_sig, roi);
   }
   //            catch(Exception e){
   //                IJ.showMessage(e.getMessage());
   //            }
   //        }
   ovr.setLabelColor(Color.WHITE);
   //        ovr.setFillColor(Color.GREEN);
   ovr.setStrokeColor(Color.getHSBColor(100, 30, 87));
   av_imp.setOverlay(ovr);
   av_imp.show();
   IJ.run("In [+]", "");
   IJ.run("In [+]", "");
   return cm;
 }
Ejemplo n.º 21
0
 @SuppressWarnings("UseJBColor")
 private static Color parseColor(String value) {
   if (value != null && value.length() == 8) {
     final Color color = ColorUtil.fromHex(value.substring(0, 6));
     if (color != null) {
       try {
         int alpha = Integer.parseInt(value.substring(6, 8), 16);
         return new ColorUIResource(
             new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha));
       } catch (Exception ignore) {
       }
     }
     return null;
   }
   return ColorUtil.fromHex(value, null);
 }
Ejemplo n.º 22
0
 /**
  * Draw character in minimap
  *
  * @param g Graphics
  * @param Dx X Displacement
  * @param Dy Y Displacement
  */
 public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) {
   // Color
   g.setColor(col.darker().darker().darker());
   g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
   g.setColor(col);
   g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
 }
  private Color getThreadBlockColor(BumpThread bt) {
    if (bt == null) return Color.BLACK;

    synchronized (thread_colors) {
      Color c = thread_colors.get(bt);
      if (c == null) {
        double v;
        int ct = thread_colors.size();
        if (ct == 0) v = 0;
        else if (ct == 1) v = 1;
        else {
          v = 0.5;
          int p0 = ct - 1;
          int p1 = 1;
          for (int p = p0; p > 1; p /= 2) {
            v /= 2.0;
            p0 -= p1;
            p1 *= 2;
          }
          if ((p0 & 1) == 0) p0 = 2 * p1 - p0 + 1;
          v = v * p0;
        }
        float h = (float) (v * 0.8);
        float s = 0.7f;
        float b = 1.0f;
        int rgb = Color.HSBtoRGB(h, s, b);
        rgb |= 0xc0000000;
        c = new Color(rgb, true);
        thread_colors.put(bt, c);
      }
      return c;
    }
  }
Ejemplo n.º 24
0
  /**
   * Class constructor alloowing specification of the heading text.
   *
   * @param properties the Properties object containing the initial values of the extensions list
   *     and the path to be displayed. This object is updated tin response to root changes,
   *     extension changes, and file selections. If any property is missing, a suitable one is
   *     supplied by default.
   * @param heading the text to appear in the heading of the JPanel.
   * @param background the background color or null if the default is to be used.
   */
  public SourcePanel(ApplicationProperties properties, String heading, Color background) {
    super();
    this.properties = properties;
    if (background == null) this.background = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    else this.background = background;

    // Make the file filter
    filter = new GeneralFileFilter();
    String extensions = properties.getProperty("extensions");
    if (extensions != null) filter.setExtensions(extensions);
    else {
      filter.addExtension(".dcm");
      properties.setProperty("extensions", filter.getExtensionString());
    }

    // Get the starting directory path from the properties.
    // If it is missing, start in the directory containing the program.
    String currentDirectoryPath = properties.getProperty("directory");
    if (currentDirectoryPath == null) currentDirectoryPath = System.getProperty("user.dir");

    // Create the UI components
    this.setLayout(new BorderLayout());
    directoryPane = new DirectoryPane(filter, currentDirectoryPath);
    directoryPane.addFileListener(this);
    headerPanel = new HeaderPanel(heading);
    footerPanel = new FooterPanel();
    this.add(headerPanel, BorderLayout.NORTH);
    this.add(directoryPane, BorderLayout.CENTER);
    this.add(footerPanel, BorderLayout.SOUTH);
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof ColorSampleLookupValue)) {
      return false;
    }

    ColorSampleLookupValue value = (ColorSampleLookupValue) o;

    if (myIsStandard != value.myIsStandard) {
      return false;
    }
    if (myColor != null ? !myColor.equals(value.myColor) : value.myColor != null) {
      return false;
    }
    if (myName != null ? !myName.equals(value.myName) : value.myName != null) {
      return false;
    }
    if (myValue != null ? !myValue.equals(value.myValue) : value.myValue != null) {
      return false;
    }

    return true;
  }
Ejemplo n.º 26
0
    /**
     * Calculates the apparent color of this polygon. We ask the camera how much light falls on a
     * surface wiith this normal and then darken the color accordingly.
     */
    private Color calcLight() {
      if (noShade) {
        return c;
      }

      int r = c.getRed();
      int g = c.getGreen();
      int b = c.getBlue();

      float light = modelViewer.cameraMan.surfaceLight(normal);

      r *= light;
      g *= light;
      b *= light;

      return new Color(r, g, b);
    }
Ejemplo n.º 27
0
  /*
  ****************** CHECKLIST ******************************
  [x] manipulate every Pixel in the Picture
  [x] The value of amount MUST control the amount of the effect

  */
  public void changeWhole(double amount) {
    int yMax = this.getHeight();
    int xMax = this.getWidth();

    Color p;

    for (int i = 0; i < xMax - 1; i++) {
      for (int j = 0; j < yMax - 1; j++) {
        p = this.getPixel(i, j).getColor();
        int R = (int) (p.getRed() * amount);
        int G = (int) (p.getBlue() * (amount));
        int B = (int) (p.getGreen() * (amount));
        Color C = new Color(G, B, R);
        this.getPixel(i, j).setColor((C));
      }
    }
  }
Ejemplo n.º 28
0
 /**
  * \ Draw saved State (color dots on panel) on WhiteBoard
  *
  * @param outstream
  * @throws IOException
  */
 public void writeState(OutputStream outstream) throws IOException {
   if (state == null) return;
   synchronized (state) {
     DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(outstream));
     // DataOutputStream dos=new DataOutputStream(outstream);
     dos.writeInt(state.size());
     for (Map.Entry<Point, Color> entry : state.entrySet()) {
       Point point = entry.getKey();
       Color col = entry.getValue();
       dos.writeInt(point.x);
       dos.writeInt(point.x);
       dos.writeInt(col.getRGB());
     }
     dos.flush();
     System.out.println("wrote " + state.size() + " elements");
   }
 }
 @Override
 public int hashCode() {
   int result = (myIsStandard ? 1 : 0);
   result = 31 * result + (myName != null ? myName.hashCode() : 0);
   result = 31 * result + (myValue != null ? myValue.hashCode() : 0);
   result = 31 * result + (myColor != null ? myColor.hashCode() : 0);
   return result;
 }
Ejemplo n.º 30
0
 /**
  * WhiteboardShapeLine constructor.
  *
  * @param id String that uniquely identifies this WhiteboardObject.
  * @param t number of pixels that this object (or its border) should be thick.
  * @param c WhiteboardShapeLine's color (or rather it's border)
  * @param startPoint the start coordinates of this line.
  * @param endPoint the end coordinates of this line.
  */
 public WhiteboardShapeLine(
     String id, int t, Color c, WhiteboardPoint startPoint, WhiteboardPoint endPoint) {
   super(id);
   this.setThickness(t);
   setColor(c);
   setColor(c.getRGB());
   this.endPoint = endPoint;
   this.startPoint = startPoint;
 }