Java Code Examples for java.awt.Color#DARK_GRAY

The following examples show how to use java.awt.Color#DARK_GRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextComponent.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
private Color getTextColor(boolean isChoice, Color choiceColor, Color interactiveColor) {
    if (isCardId() && !isChoice) {
        return Color.DARK_GRAY;
    }
    if (isInteractive() && messageStyle != MessageStyle.PLAINBOLDMONO) {
        return interactiveColor;
    }
    if ("(".equals(text) || ")".equals(text)) {
        return messageStyle != MessageStyle.PLAINBOLDMONO
            ? interactiveColor
            : choiceColor;
    }
    if (isChoice) {
        return choiceColor;
    }
    return Color.BLACK;
}
 
Example 2
Source File: ColorComboBox.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * C'tor
 * The combo box is initialized with some basic colors and user can also
 * pick a custom color
 */
public ColorComboBox() {
    this( new Color[] {
        Color.BLACK,
        Color.BLUE,
        Color.CYAN,
        Color.DARK_GRAY,
        Color.GRAY,
        Color.GREEN,
        Color.LIGHT_GRAY,
        Color.MAGENTA,
        Color.ORANGE,
        Color.PINK,
        Color.RED,
        Color.WHITE,
        Color.YELLOW,
        }, new String[0], true);
}
 
Example 3
Source File: ColorChooserPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected JComponent createColorPicker() {

        Color[] colors = {Color.BLACK,
                Color.DARK_GRAY,
                Color.GRAY,
                Color.LIGHT_GRAY,
                Color.WHITE,
                Color.CYAN,
                Color.BLUE,
                Color.MAGENTA,
                Color.YELLOW,
                Color.ORANGE,
                Color.RED,
                Color.PINK,
                Color.GREEN};


        JPanel colorsPanel = new JPanel(new GridLayout(-1, 6, 4, 4));
        colorsPanel.setOpaque(false);
        for (Color color : colors) {
            ColorLabel colorLabel = new ColorLabel(color);
            colorLabel.setDisplayName(ColorCodes.getName(color));
            colorLabel.setHoverEnabled(true);
            colorLabel.setMaximumSize(colorLabel.getPreferredSize());
            colorLabel.setMinimumSize(colorLabel.getPreferredSize());
            colorLabel.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    setSelectedColor(colorLabel.getColor());
                }
            });
            colorsPanel.add(colorLabel);
        }
        return colorsPanel;
    }
 
Example 4
Source File: EdgeColorPlugin.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
  public boolean apply(EdgeRenderingProperty p) {
    NodeRenderingProperty node1 = p.node1;
    NodeRenderingProperty node2 = p.node2;

    if (node1.isSelected() && node2.isSelected()) {
      // both ends of the edge is selected.
      p.targetStrokeColor = Color.DARK_GRAY;
    } else if (node1.isSelected()) {
      // edges to the child of the selected node in blue
      p.targetStrokeColor = Color.RED;
    } else if (node2.isSelected()) {
      // edges to the parent of the selected node in red
      p.targetStrokeColor = Color.BLUE;
    } else if (p.overriddenStrokeColor != null) {
      p.targetStrokeColor = p.overriddenStrokeColor;
// TODO(yohann): Reimplement this with help from plugins
/*
    } else if (containerFinder.matchForward(p.edge.getRelation())
        || containerFinder.matchBackward(p.edge.getRelation())) {
      // not picked, draw container edges with distinctive color
      p.targetStrokeColor = Color.GRAY;
*/
    } else {
      p.targetStrokeColor = Color.LIGHT_GRAY;
    }
    return true;
  }
 
Example 5
Source File: ChatLogArea.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
private void initColors() {
	Color endColor;

	Style style = StyleUtil.getStyle();
	if (style != null) {
		colors[0] = style.getHighLightColor();
		endColor = style.getPlainColor();
	} else {
		colors[0] = Color.BLUE;
		endColor = Color.DARK_GRAY;
	}

	int r = colors[0].getRed();
	int g = colors[0].getGreen();
	int b = colors[0].getBlue();
	int alpha = 0xff;
	int rDelta = r - endColor.getRed();
	int gDelta = g - endColor.getGreen();
	int bDelta = b - endColor.getBlue();
	int alphaDelta;
	if (TransparencyMode.TRANSPARENCY == Transparency.TRANSLUCENT) {
		alphaDelta = 0xff / STEPS;
	} else {
		alphaDelta = 0;
	}
	for (int i = 1; i < STEPS; i++) {
		alpha -= alphaDelta;
		colors[i] = new Color(r - i * rDelta / STEPS, g - i * gDelta / STEPS, b - i * bDelta / STEPS, alpha);
	}
}
 
Example 6
Source File: GridPanel.java    From Rails with GNU General Public License v2.0 5 votes vote down vote up
public GridPanel() {
    //initialize border colors according to the configuration
    if ("enabled".equals(Config.get("gridPanel.tableBorders"))) {
        tableBorderColor = Color.DARK_GRAY;
        cellOutlineColor = Color.GRAY;
        highlightedBorderColor = Color.RED;
    } else {
        tableBorderColor = getBackground();
        cellOutlineColor = getBackground();
        highlightedBorderColor = Color.RED;
    }
}
 
Example 7
Source File: ColorTranslator.java    From petscii-bbs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Translates the specified color number.
 * 
 * @param colornum the color number
 * @param defaultColor the default color
 * @return the color for the number
 */
public Color translate(int colornum, int defaultColor) {
  
  switch (colornum) {
  
  case COLOR_DEFAULT:
    return translate(defaultColor, UNDEFINED);
  case COLOR_BLACK:
    return Color.BLACK;
  case COLOR_RED:
    return RED;
  case COLOR_GREEN:
    return GREEN;
  case COLOR_YELLOW:
    return YELLOW;
  case COLOR_BLUE:
    return BLUE;
  case COLOR_MAGENTA:
    return MAGENTA;
  case COLOR_CYAN:
    return CYAN;
  case COLOR_WHITE:
    return Color.WHITE;
  case COLOR_MS_DOS_DARKISH_GREY:
    return Color.DARK_GRAY;
  }
  return Color.BLACK;
}
 
Example 8
Source File: PanelCanvas.java    From nanoleaf-desktop with MIT License 5 votes vote down vote up
private void startLoadingSpinner()
{
	if (devices != null && devices[0] == null)
	{
		spinner = new LoadingSpinner(Color.DARK_GRAY);
		add(spinner);
	}
}
 
Example 9
Source File: AbstractQuickSearchComboBar.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static Color getCategoryTextColor () {
    Color shadow = UIManager.getColor("textInactiveText");
    if( "Aqua".equals(UIManager.getLookAndFeel().getID()) )
        shadow = UIManager.getColor("Table.foreground");
    return shadow != null ? shadow : Color.DARK_GRAY;
}
 
Example 10
Source File: GtkLFCustoms.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object[] createLookAndFeelCustomizationKeysAndValues() {
    if (ThemeValue.functioning()) {
        return new Object[] {
            //XXX once the JDK team has integrated support for standard
            //UIManager keys into 1.5 (not there as of b47), these can 
            //probably be deleted, resulting in a performance improvement:
            "control", control,
            "controlHighlight", new ThemeValue (Region.PANEL, ThemeValue.LIGHT, Color.LIGHT_GRAY), //NOI18N
            "controlShadow", new ThemeValue (Region.PANEL, ThemeValue.DARK, Color.DARK_GRAY), //NOI18N
            "controlDkShadow", new ThemeValue (Region.PANEL, ThemeValue.BLACK, Color.BLACK), //NOI18N
            "controlLtHighlight", new ThemeValue (Region.PANEL, ThemeValue.WHITE, Color.WHITE), //NOI18N
            "textText", new ThemeValue (Region.PANEL, ColorType.TEXT_FOREGROUND, Color.BLACK), //NOI18N
            "text", new ThemeValue (Region.PANEL, ColorType.TEXT_BACKGROUND, Color.GRAY), //NOI18N
            
            "tab_unsel_fill", control, //NOI18N
             
            "SplitPane.dividerSize", new Integer (2),  //NOI18N
            
            SYSTEMFONT, controlFont, //NOI18N
            USERFONT, controlFont, //NOI18N
            MENUFONT, controlFont, //NOI18N
            LISTFONT, controlFont, //NOI18N
            "Label.font", controlFont, //NOI18N
            "Panel.font", controlFont, //NOI18N

            // workaround: GTKLookAndFeel FileChooser is unusable, cannot
            // choose a dir and doesn't look native anyway.  We force MetalFileChooserUI
                    
            "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI", // NOI18N
            "FileView.computerIcon",       javax.swing.plaf.metal.MetalIconFactory.getTreeComputerIcon(), // NOI18N
            "FileView.hardDriveIcon",      javax.swing.plaf.metal.MetalIconFactory.getTreeHardDriveIcon(), // NOI18N
            "FileView.floppyDriveIcon",    javax.swing.plaf.metal.MetalIconFactory.getTreeFloppyDriveIcon(), // NOI18N
            "FileChooser.newFolderIcon",   javax.swing.plaf.metal.MetalIconFactory.getFileChooserNewFolderIcon(), // NOI18N
            "FileChooser.upFolderIcon",    javax.swing.plaf.metal.MetalIconFactory.getFileChooserUpFolderIcon(), // NOI18N
            "FileChooser.homeFolderIcon",  javax.swing.plaf.metal.MetalIconFactory.getFileChooserHomeFolderIcon(), // NOI18N
            "FileChooser.detailsViewIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserDetailViewIcon(), // NOI18N
            "FileChooser.listViewIcon",    javax.swing.plaf.metal.MetalIconFactory.getFileChooserListViewIcon(), // NOI18N
            "FileChooser.usesSingleFilePane", Boolean.TRUE, // NOI18N
            "FileChooser.ancestorInputMap", // NOI18N
                        new UIDefaults.LazyInputMap(new Object[] {
                            "ESCAPE", "cancelSelection", // NOI18N
                            "F2", "editFileName", // NOI18N
                            "F5", "refresh", // NOI18N
                            "BACK_SPACE", "Go Up", // NOI18N
                            "ENTER", "approveSelection", // NOI18N
                            "ctrl ENTER", "approveSelection" // NOI18N
                        }),
            // special tree icons - only for property sheet
            "Tree.gtk_expandedIcon", new GTKExpandedIcon(),
            "Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
        };
    } else {
        Object[] result = new Object[] {
            TOOLBAR_UI, new UIDefaults.ProxyLazyValue("org.netbeans.swing.plaf.gtk.GtkToolbarUI"), //NOI18N
            // special tree icons - only for property sheet
            "Tree.gtk_expandedIcon", new GTKExpandedIcon(),
            "Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
        };
        return result;
    }
}
 
Example 11
Source File: CommonEvents.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
public static String getCaptcha(HttpServletRequest request, HttpServletResponse response) {
    try {
        Delegator delegator = (Delegator) request.getAttribute("delegator");
        final String captchaSizeConfigName = StringUtils.defaultIfEmpty(request.getParameter("captchaSize"), "default");
        final String captchaSizeConfig = EntityUtilProperties.getPropertyValue("captcha", "captcha." + captchaSizeConfigName, delegator);
        final String[] captchaSizeConfigs = captchaSizeConfig.split("\\|");
        final String captchaCodeId = StringUtils.defaultIfEmpty(request.getParameter("captchaCodeId"), ""); // this is used to uniquely identify in the user session the attribute where the captcha code for the last captcha for the form is stored

        final int fontSize = Integer.parseInt(captchaSizeConfigs[0]);
        final int height = Integer.parseInt(captchaSizeConfigs[1]);
        final int width = Integer.parseInt(captchaSizeConfigs[2]);
        final int charsToPrint = UtilProperties.getPropertyAsInteger("captcha", "captcha.code_length", 6);
        final char[] availableChars = EntityUtilProperties.getPropertyValue("captcha", "captcha.characters", delegator).toCharArray();

        //It is possible to pass the font size, image width and height with the request as well
        Color backgroundColor = Color.gray;
        Color borderColor = Color.DARK_GRAY;
        Color textColor = Color.ORANGE;
        Color circleColor = new Color(160, 160, 160);
        Font textFont = new Font("Arial", Font.PLAIN, fontSize);
        int circlesToDraw = 6;
        float horizMargin = 20.0f;
        double rotationRange = 0.7; // in radians
        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

        Graphics2D g = (Graphics2D) bufferedImage.getGraphics();

        g.setColor(backgroundColor);
        g.fillRect(0, 0, width, height);

        //Generating some circles for background noise
        g.setColor(circleColor);
        for (int i = 0; i < circlesToDraw; i++) {
            int circleRadius = (int) (Math.random() * height / 2.0);
            int circleX = (int) (Math.random() * width - circleRadius);
            int circleY = (int) (Math.random() * height - circleRadius);
            g.drawOval(circleX, circleY, circleRadius * 2, circleRadius * 2);
        }
        g.setColor(textColor);
        g.setFont(textFont);

        FontMetrics fontMetrics = g.getFontMetrics();
        int maxAdvance = fontMetrics.getMaxAdvance();
        int fontHeight = fontMetrics.getHeight();

        String captchaCode = RandomStringUtils.random(6, availableChars);

        float spaceForLetters = -horizMargin * 2 + width;
        float spacePerChar = spaceForLetters / (charsToPrint - 1.0f);

        for (int i = 0; i < captchaCode.length(); i++) {

            // this is a separate canvas used for the character so that
            // we can rotate it independently
            int charWidth = fontMetrics.charWidth(captchaCode.charAt(i));
            int charDim = Math.max(maxAdvance, fontHeight);
            int halfCharDim = (charDim / 2);

            BufferedImage charImage = new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
            Graphics2D charGraphics = charImage.createGraphics();
            charGraphics.translate(halfCharDim, halfCharDim);
            double angle = (Math.random() - 0.5) * rotationRange;
            charGraphics.transform(AffineTransform.getRotateInstance(angle));
            charGraphics.translate(-halfCharDim, -halfCharDim);
            charGraphics.setColor(textColor);
            charGraphics.setFont(textFont);

            int charX = (int) (0.5 * charDim - 0.5 * charWidth);
            charGraphics.drawString("" + captchaCode.charAt(i), charX,
                    ((charDim - fontMetrics.getAscent()) / 2 + fontMetrics.getAscent()));

            float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
            int y = ((height - charDim) / 2);

            g.drawImage(charImage, (int) x, y, charDim, charDim, null, null);

            charGraphics.dispose();
        }
        // Drawing the image border
        g.setColor(borderColor);
        g.drawRect(0, 0, width - 1, height - 1);
        g.dispose();
        response.setContentType("image/jpeg");
        ImageIO.write(bufferedImage, "jpg", response.getOutputStream());
        HttpSession session = request.getSession();
        Map<String, String> captchaCodeMap = UtilGenerics.checkMap(session.getAttribute("_CAPTCHA_CODE_"));
        if (captchaCodeMap == null) {
            captchaCodeMap = new HashMap<>();
            session.setAttribute("_CAPTCHA_CODE_", captchaCodeMap);
        }
        captchaCodeMap.put(captchaCodeId, captchaCode);
    } catch (IOException | IllegalArgumentException | IllegalStateException ioe) {
        Debug.logError(ioe.getMessage(), module);
    }
    return "success";
}
 
Example 12
Source File: AqlDisplay.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Paint getColor(Kind k) {
	switch (k) {
	case CONSTRAINTS:
		return Color.BLUE;
	case TYPESIDE:
		return Color.WHITE;
	case SCHEMA:
		return Color.GRAY;
	case INSTANCE:
		return Color.black;
	case MAPPING:
		return Color.LIGHT_GRAY;
	case TRANSFORM:
		return Color.DARK_GRAY;
	case QUERY:
		return Color.RED;
	case PRAGMA:
		return Color.GREEN;
	case GRAPH:
		return Color.YELLOW;
	case COMMENT:
		return Color.PINK;
	case SCHEMA_COLIMIT:
		return Color.ORANGE;
	case THEORY_MORPHISM:
		return Color.gray;
		
	case APG_instance:
		return Color.black;	
	case APG_typeside:
		return Color.WHITE;
	case APG_morphism:
		return Color.gray;
	case APG_mapping:
		return Color.red;
	case APG_schema:
		return Color.pink;
	default:
		break;
		
	}
	return Util.anomaly();
}
 
Example 13
Source File: PageListCellRenderer.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
@Override
public Component getListCellRendererComponent(
    JList<? extends Page> list,
    Page value,
    @SuppressWarnings("unused") int index,
    boolean isSelected,
    @SuppressWarnings("unused") boolean cellHasFocus) {

  // Retrieve data
  String pageName = (value != null) ? value.toString() : "";
  String text = pageName;
  Boolean disambiguation = null;
  Boolean exist = null;
  boolean redirect = false;
  InternalLinkCount count = null;
  if (value != null) {
    Page pageElement = value;
    pageName = pageElement.getTitle();
    text = pageName;
    disambiguation = pageElement.isDisambiguationPage();
    exist = pageElement.isExisting();
    count = (analysis != null) ? analysis.getLinkCount(pageElement) : null;
    if (showCountOccurrence &&
        (count != null) &&
        (count.getTotalLinkCount() > 0)) {
      text += " → " + count.getTotalLinkCount(); 
    }
    redirect = pageElement.getRedirects().isRedirect();
    if (redirect && showRedirectBacklinks) {
      Integer backlinks = pageElement.getBacklinksCountInMainNamespace();
      if ((backlinks != null) && (backlinks.intValue() > 0)) {
        text += " ← " + backlinks;
      }
    }
  }

  // Text
  setText(text);

  // Color
  Color background = isSelected ? list.getSelectionBackground() : Color.WHITE;
  Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();
  if (showDisambiguation) {
    if (disambiguation == null) {
      if (!isSelected) {
        foreground = Color.DARK_GRAY;
      }
    } else if (disambiguation.booleanValue()) {
      if (count == null) {
        foreground = Color.RED;
      } else if ((count.getInternalLinkCount() > 0) || (count.getIncorrectTemplateCount() > 0)) {
        foreground = Color.RED;
      } else if ((count.getHelpNeededCount() > 0)) {
        foreground = Color.ORANGE;
      } else {
        foreground = Color.BLUE;
      }
    }
  } else if (pageProperties != null) {
    String property = pageProperties.getProperty(pageName);
    if (Configuration.VALUE_PAGE_NORMAL.equals(property)) {
      foreground = Color.GREEN;
    } else if (Configuration.VALUE_PAGE_HELP_NEEDED.equals(property)) {
      foreground = Color.ORANGE;
    }
  }
  setBackground(background);
  setForeground(foreground);

  // Font
  if (showMissing && Boolean.FALSE.equals(exist)) {
    setFont(missingFont);
  } else if (showRedirect && redirect) {
    setFont(redirectFont);
  } else {
    setFont(normalFont);
  }

  return this;
}
 
Example 14
Source File: SSD1331Test.java    From diozero with MIT License 4 votes vote down vote up
public static void animateText(SsdOled oled, String text) {
	int width = oled.getWidth();
	int height = oled.getHeight();
	BufferedImage image = new BufferedImage(width, height, oled.getNativeImageType());
	Graphics2D g2d = image.createGraphics();
	Random random = new Random();
	
	Color[] colours = { Color.WHITE, Color.BLUE, Color.CYAN, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY,
			Color.MAGENTA, Color.ORANGE, Color.PINK, Color.RED, Color.YELLOW };
	g2d.setBackground(Color.BLACK);
	
	Font f = g2d.getFont();
	Logger.info("Font name={}, family={}, size={}, style={}", f.getFontName(), f.getFamily(),
			Integer.valueOf(f.getSize()), Integer.valueOf(f.getStyle()));
	FontMetrics fm = g2d.getFontMetrics();
	int maxwidth = fm.stringWidth(text);
	
	int amplitude = height/4;
	int offset = height/2 - 4;
	int velocity = -2;
	int startpos = width;
	int pos = startpos;
	int x;
	for (int i=0; i<200; i++) {
		g2d.clearRect(0, 0, width, height);
		x = pos;

		for (char c : text.toCharArray()) {
			if (x > width) {
				break;
			}
			
			if (x < -10) {
				x += fm.charWidth(c);
				continue;
			}
			// Calculate offset from sine wave.
	        int y = (int) (offset + Math.floor(amplitude * Math.sin(x / ((float)width) * 2.0 * Math.PI)));
	        // Draw text.
			g2d.setColor(colours[random.nextInt(colours.length)]);
	        g2d.drawString(String.valueOf(c), x, y);
	        // Increment x position based on chacacter width.
	        x += fm.charWidth(c);
		}
	    // Draw the image buffer.
	    oled.display(image);
	    // Move position for next frame.
	    pos += velocity;
	    // Start over if text has scrolled completely off left side of screen.
	    if (pos < -maxwidth) {
	        pos = startpos;
	    }
	    
	    // Pause briefly before drawing next frame.
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
		}
	}
}
 
Example 15
Source File: PropertyManagerTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/** Test method for {@link com.sldeditor.common.property.PropertyManager#readConfig()}. */
@Test
public void testReadConfig() {
    PropertyManager nullPropertyManager = new PropertyManager();
    nullPropertyManager.setPropertyFile(null);
    nullPropertyManager.readConfig();

    File file = null;
    try {
        file = File.createTempFile(getClass().getSimpleName(), ".properties");
    } catch (IOException e) {
        e.printStackTrace();
        fail("Failed to create test property temporary file");
    }
    PropertyManager propertyManager = new PropertyManager();
    propertyManager.setPropertyFile(file);

    String stringKey = "string key";
    String stringValue = "test string value";
    propertyManager.updateValue(stringKey, stringValue);

    String colourKey = "colour key";
    Color colourValue = Color.DARK_GRAY;
    propertyManager.updateValue(colourKey, colourValue);

    String booleanKey = "boolean key";
    boolean booleanValue = true;
    propertyManager.updateValue(booleanKey, booleanValue);

    List<String> stringList = new ArrayList<String>();
    stringList.add("item 1");
    stringList.add("item 2");
    stringList.add("item 3");
    String stringListKey = "string list key";
    propertyManager.updateValue(stringListKey, stringList);

    String stringMultipleKey = "multiple string key";
    int index = 0;
    for (String value : stringList) {
        propertyManager.updateValue(stringMultipleKey, index, value);
        index++;
    }

    PropertyManager testPropertyManager = new PropertyManager();
    testPropertyManager.setPropertyFile(file);
    testPropertyManager.readConfig();

    Color actualColourResult = testPropertyManager.getColourValue(colourKey, Color.black);
    assertEquals(colourValue, actualColourResult);

    boolean actualBooleanResult = testPropertyManager.getBooleanValue(booleanKey, false);
    assertEquals(booleanValue, actualBooleanResult);

    String actualStringResult = testPropertyManager.getStringValue(stringKey, "");
    assertEquals(stringValue, actualStringResult);

    List<String> actualStringList = testPropertyManager.getStringListValue(stringListKey);
    assertEquals(stringList, actualStringList);

    actualStringList = testPropertyManager.getMultipleValues(stringMultipleKey);
    assertEquals(stringList, actualStringList);

    file.delete();
}
 
Example 16
Source File: ColorizedBubbleRenderer.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Paint getItemOutlinePaint(int series, int item) {
	return Color.DARK_GRAY;
}
 
Example 17
Source File: ResultsProccessor.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    calcMeans();
    calcAvgRulesBySeed();
    
    // Create JFreeChart Dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
    
    
    HashMap<String, Double> measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, Double> measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            Double measureValue = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.addValue(measureValue, aName, measureName);
            
            ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
            JFreeChart barChart = ChartFactory.createBarChart("Assotiation Rules Measures", measureName, measureName, dataset, PlotOrientation.VERTICAL, true, true, false);
            StandardChartTheme.createLegacyTheme().apply(barChart);
            
            CategoryItemRenderer renderer = barChart.getCategoryPlot().getRenderer();
            
            // Black and White
            int numItems = algorithmMeasures.size();
            for(int i=0;i<numItems;i++)
            {
                Color color = Color.DARK_GRAY;
                if(i%2 == 1)
                {
                    color = Color.LIGHT_GRAY;
                }
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesOutlinePaint(i, Color.BLACK);
            }
            
            
            int width = 640 * 2; /* Width of the image */
            int height = 480 * 2; /* Height of the image */ 
            
            // JPEG
            File BarChart = new File( outName + "_" + measureName + "_barchart.jpg" );
            ChartUtilities.saveChartAsJPEG( BarChart , barChart , width , height );
            
            // SVG
            SVGGraphics2D g2 = new SVGGraphics2D(width, height);
            Rectangle r = new Rectangle(0, 0, width, height);
            barChart.draw(g2, r);
            File BarChartSVG = new File( outName + "_" + measureName + "_barchart.svg" );
            SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
        }
    }
    /*
    for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
    {
        String alg = entry.getKey();
        HashMap<String, Double> measures = entry.getValue();
        
        for (Map.Entry<String, Double> entry1 : measures.entrySet())
        {
            String measureName = entry1.getKey();
            Double measureValue = entry1.getValue();
            
            dataset.addValue(measureValue, alg, measureName);
        }
    }
            */
    
}
 
Example 18
Source File: ResultsProccessor.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    //calcMeans();
    
    // Create JFreeChart Dataset
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset( );
    
    
    HashMap<String, ArrayList<Double> > measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, ArrayList<Double> > measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, ArrayList<Double> >> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            ArrayList<Double> measureValues = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.add(measureValues, aName, measureName);
        }
        
        // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
        final CategoryAxis xAxis = new CategoryAxis("Algorithm");
        final NumberAxis yAxis = new NumberAxis("Value");
        yAxis.setAutoRangeIncludesZero(false);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        
        // Black and White
        int numItems = algorithmMeasures.size();
        for(int i=0;i<numItems;i++)
        {
            Color color = Color.DARK_GRAY;
            if(i%2 == 1)
            {
                color = Color.LIGHT_GRAY;
            }
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesOutlinePaint(i, Color.BLACK);
        }
        
        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

        Font font = new Font("SansSerif", Font.BOLD, 10);
        //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
        JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
        //StandardChartTheme.createLegacyTheme().apply(jchart);
     
        int width = 640 * 2; /* Width of the image */
        int height = 480 * 2; /* Height of the image */ 

        // JPEG
        File chart = new File( outName + "_" + measureName + "_boxplot.jpg" );
        ChartUtilities.saveChartAsJPEG( chart , jchart , width , height );

        // SVG
        SVGGraphics2D g2 = new SVGGraphics2D(width, height);
        Rectangle r = new Rectangle(0, 0, width, height);
        jchart.draw(g2, r);
        File BarChartSVG = new File( outName + "_" + measureName + "_boxplot.svg" );
        SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
    }
    
}
 
Example 19
Source File: UnitOverview.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
private Color getFrameColor(Entity entity) {
    if (!clientgui.getClient().isMyTurn() || !entity.isSelectableThisTurn()) {
        return Color.DARK_GRAY;
    }
    return Color.black;
}
 
Example 20
Source File: CheckErrorPageListCellRenderer.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
@Override
public Component getListCellRendererComponent(
    JList<? extends CheckErrorPage> list,
    CheckErrorPage value,
    @SuppressWarnings("unused") int index,
    boolean isSelected,
    @SuppressWarnings("unused") boolean cellHasFocus) {

  // Retrieve data
  String text = (value != null) ? value.toString() : "";
  Boolean errorsPresent = null;
  Boolean globalFix = null;
  boolean whiteList = false;
  if (value != null) {
    CheckErrorPage errorPage = value;
    whiteList = errorPage.isInWhiteList();
    if (forPage && (errorPage.getPage() != null)) {
      text = errorPage.getPage().getTitle();
    } else {
      text = errorPage.getAlgorithm().toString();
      int errorCount = errorPage.getActiveResultsCount();
      if (errorCount > 0) {
        errorsPresent = Boolean.TRUE;
        if ((showCountOccurence) &&
            (errorCount > 1)) {
          text += " (" + errorCount + ")";
        }
      } else if (errorPage.getErrorFound()) {
        errorsPresent = Boolean.TRUE;
      } else {
        errorsPresent = Boolean.FALSE;
      }
      String[] globalFixes = errorPage.getAlgorithm().getGlobalFixes();
      if ((globalFixes != null) && (globalFixes.length > 0)) {
        globalFix = Boolean.TRUE;
      }
    }
  }

  // Text
  setText(text);
  if (Boolean.TRUE.equals(globalFix)) {
    setIcon(globalFixIcon);
  } else {
    setIcon(null);
  }

  // Color
  Color background = isSelected ? new Color(230, 230, 230) : Color.WHITE;
  Color foreground = list.getForeground();
  if (forPage) {
    if (whiteList) {
      foreground = Color.GREEN;
    }
  } else if (errorsPresent == null) {
    if (!isSelected) {
      foreground = Color.DARK_GRAY;
    }
  } else if (whiteList) {
    foreground = Color.GREEN;
  } else if (errorsPresent.booleanValue()) {
    foreground = Color.RED;
  }
  setBackground(background);
  setForeground(foreground);

  return this;
}