Java Code Examples for java.awt.Color#magenta()

The following examples show how to use java.awt.Color#magenta() . These examples are extracted from open source projects. 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 Project: TrakEM2   File: Merger.java    License: GNU General Public License v3.0 6 votes vote down vote up
Color getColor() {
	if (c.identical()) return Color.white;
	if (c.hasSimilarNodes()) {
		if (c.d1_only > 0 && c.d2_only > 0) {
			// Mixed changes: problem
			return Color.magenta;
		} else if (c.d1_only > 0) {
			// Changes only in d1
			return Color.orange;
		} else if (c.d2_only > 0) {
			// Changes only in d2
			return Color.pink;
		}
		// Same for tags
		if (c.tags_1_only > 0 && c.tags_2_only > 0) {
			return Color.magenta;
		} else if (c.tags_1_only > 0) {
			return Color.orange;
		} else if (c.tags_2_only > 0) {
			return Color.pink;
		}
	}
	return Color.red.brighter();
}
 
Example 2
/**
 * Returns the default style table. This can be passed to the <code>setStyles()</code> method of
 * <code>SyntaxDocument</code> to use the default syntax styles.
 */
public static SyntaxStyle[] getDefaultSyntaxStyles() {
	SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];

	styles[Token.COMMENT1] = new SyntaxStyle(Color.black, true, false);
	styles[Token.COMMENT2] = new SyntaxStyle(new Color(0x990033), true, false);
	styles[Token.KEYWORD1] = new SyntaxStyle(Color.black, false, true);
	styles[Token.KEYWORD2] = new SyntaxStyle(Color.magenta, false, false);
	styles[Token.KEYWORD3] = new SyntaxStyle(new Color(0x009600), false, false);
	styles[Token.LITERAL1] = new SyntaxStyle(new Color(0x650099), false, false);
	styles[Token.LITERAL2] = new SyntaxStyle(new Color(0x650099), false, true);
	styles[Token.LABEL] = new SyntaxStyle(new Color(0x990033), false, true);
	styles[Token.OPERATOR] = new SyntaxStyle(Color.black, false, true);
	styles[Token.INVALID] = new SyntaxStyle(Color.red, false, true);

	return styles;
}
 
Example 3
protected void decideColors(Color aColor) {
  if(aColor==null) {
    return;
  }
  defaultColor = aColor;
  if(defaultColor.equals(Color.yellow)) {
    editingColor = Color.orange;
  } else {
    editingColor = Color.yellow;
  }
  if(defaultColor.equals(Color.red)) {
    errorColor = Color.magenta;
  } else {
    errorColor = Color.red;
  }
}
 
Example 4
/**
     * Get common color
     *
     * @param idx Index
     * @return Common color
     */
    public static Color getCommonColor(int idx) {
//        if (idx == 0) {
//            idx = 1;
//        }
        if (idx > 11) {
            idx = idx % 11;
        }

        switch (idx) {
            case 0:
                return Color.red;
            case 1:
                return Color.blue;
            case 2:
                return Color.green;
            case 3:
                return Color.black;
            case 4:
                return Color.yellow;
            case 5:
                return Color.pink;
            case 6:
                return Color.gray;
            case 7:
                return Color.cyan;
            case 8:
                return Color.magenta;
            case 9:
                return Color.orange;
            case 10:
                return Color.darkGray;
            case 11:
                return Color.lightGray;
        }

        return Color.red;
    }
 
Example 5
public static Color getColor(String string)
{
    if (string.equals("blue"))
        return Color.blue;
    if (string.equals("cyan"))
        return Color.cyan;
    if (string.equals("green"))
        return Color.green;
    if (string.equals("gray"))
        return Color.lightGray;
    if (string.equals("magenta"))
        return Color.magenta;
    if (string.equals("pink"))
        return Color.pink;
    if (string.equals("red"))
        return Color.red;
    if (string.equals("yellow"))
        return Color.yellow;
    if (string.equals("black"))
        return Color.black;
    if (string.equals("white"))
        return Color.white;
    try
    {
        return Color.decode(string);
    }
    catch (NumberFormatException e)
    {
        return null;
    }
}
 
Example 6
Source Project: netbeans   File: BrowserDisplayer.java    License: Apache License 2.0 5 votes vote down vote up
/**
    * Sets the text Color for the activator text.
    * The following is a list of supported Color names
    * <ul>
    * <li>black
    * <li>blue
    * <li>cyan
    * <li>darkGray
    * <li>gray
    * <li>green
    * <li>lightGray
    * <li>magenta
    * <li>orange
    * <li>pink
    * <li>red
    * <li>white
    * <li>yellow
    * </ul>
    */
   public void setTextColor(String name) {
Color color=null;
if ("black".equals(name)) {
    color = Color.black;
} else if ("blue".equals(name)) {
    color = Color.blue;
} else if ("cyan".equals(name)) {
    color = Color.cyan;
} else if ("darkGray".equals(name)) {
    color = Color.darkGray;
} else if ("gray".equals(name)) {
    color = Color.gray;
} else if ("green".equals(name)) {
    color = Color.green;
} else if ("lightGray".equals(name)) {
    color = Color.lightGray;
} else if ("magenta".equals(name)) {
    color = Color.magenta;
} else if ("orange".equals(name)) {
    color = Color.orange;
} else if ("pink".equals(name)) {
    color = Color.pink;
} else if ("red".equals(name)) {
    color = Color.red;
} else if ("white".equals(name)) {
    color = Color.white;
} else if ("yellow".equals(name)) {
    color = Color.yellow;
}

if (color == null) {
    return;
}
textAttribs.removeAttribute(StyleConstants.Foreground);
textAttribs.addAttribute(StyleConstants.Foreground, color);
setForeground(color);
   }
 
Example 7
public Object getTokenColoring(TokenContextPath tokenContextPath,
TokenCategory tokenIDOrCategory, boolean printingSet) {

    if (!printingSet) {
        switch (tokenIDOrCategory.getNumericID()) {
            case PropertiesTokenContext.KEY_ID:
                return new Coloring(boldFont, Coloring.FONT_MODE_APPLY_STYLE,
                        Color.blue, null);

            case PropertiesTokenContext.EQ_ID:
            case PropertiesTokenContext.TEXT_ID:
                return emptyColoring;

            case PropertiesTokenContext.LINE_COMMENT_ID:
                return new Coloring(italicFont, Coloring.FONT_MODE_APPLY_STYLE,
                        Color.gray, null);

            case PropertiesTokenContext.VALUE_ID:
                return new Coloring(null, Color.magenta, null);
        }



    } else { // printing set
        switch (tokenIDOrCategory.getNumericID()) {

            default:
                 return SettingsUtil.defaultPrintColoringEvaluator;
        }

    }

    return null;

}
 
Example 8
private Color randomColor() {
	Color colors[] = {Color.black, Color.blue, Color.cyan,
		Color.gray, Color.darkGray, Color.green,
		Color.lightGray, Color.magenta, Color.orange,
		Color.pink,Color.red, Color.white, Color.yellow};
	return colors[(int)(Math.random() * colors.length)];
}
 
Example 9
/**
 * Demonstrates the use of layers.
 * 
 * @param args
 *            no arguments needed
 */
@Test
public void main() throws Exception {
	// step 1: creation of a document-object
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2: creation of the writer
	PdfWriter writer = PdfWriter.getInstance(document,
			PdfTestBase.getOutputStream("optionalcontent.pdf"));
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	writer.setViewerPreferences(PdfWriter.PageModeUseOC);
	// step 3: opening the document
	document.open();
	// step 4: content
	PdfContentByte cb = writer.getDirectContent();
	Phrase explanation = new Phrase(
			"Automatic layers, form fields, images, templates and actions",
			new Font(Font.HELVETICA, 18, Font.BOLD, Color.red));
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
			650, 0);
	PdfLayer l1 = new PdfLayer("Layer 1", writer);
	PdfLayer l2 = new PdfLayer("Layer 2", writer);
	PdfLayer l3 = new PdfLayer("Layer 3", writer);
	PdfLayer l4 = new PdfLayer("Form and XObject Layer", writer);
	PdfLayerMembership m1 = new PdfLayerMembership(writer);
	m1.addMember(l2);
	m1.addMember(l3);
	Phrase p1 = new Phrase("Text in layer 1");
	Phrase p2 = new Phrase("Text in layer 2 or layer 3");
	Phrase p3 = new Phrase("Text in layer 3");
	cb.beginLayer(l1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0f);
	cb.endLayer();
	cb.beginLayer(m1);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
	cb.endLayer();
	cb.beginLayer(l3);
	ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
	cb.endLayer();
	TextField ff = new TextField(writer, new Rectangle(200, 600, 300, 620),
			"field1");
	ff.setBorderColor(Color.blue);
	ff.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
	ff.setBorderWidth(TextField.BORDER_WIDTH_THIN);
	ff.setText("I'm a form field");
	PdfFormField form = ff.getTextField();
	form.setLayer(l4);
	writer.addAnnotation(form);
	Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
			+ "pngnow.png");
	img.setLayer(l4);
	img.setAbsolutePosition(200, 550);
	cb.addImage(img);
	PdfTemplate tp = cb.createTemplate(100, 20);
	Phrase pt = new Phrase("I'm a template", new Font(Font.HELVETICA, 12,
			Font.NORMAL, Color.magenta));
	ColumnText.showTextAligned(tp, Element.ALIGN_LEFT, pt, 0, 0, 0);
	tp.setLayer(l4);
	tp.setBoundingBox(new Rectangle(0, -10, 100, 20));
	cb.addTemplate(tp, 200, 500);
	ArrayList<Object> state = new ArrayList<Object>();
	state.add("toggle");
	state.add(l1);
	state.add(l2);
	state.add(l3);
	state.add(l4);
	PdfAction action = PdfAction.setOCGstate(state, true);
	Chunk ck = new Chunk("Click here to toggle the layers", new Font(
			Font.HELVETICA, 18, Font.NORMAL, Color.yellow)).setBackground(
			Color.blue).setAction(action);
	ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(ck),
			250, 400, 0);
	cb.sanityCheck();

	// step 5: closing the document
	document.close();
}
 
Example 10
private static Color parseColor(String color) {
	if(color != null) {
		if(color.trim().startsWith("#")){
			// HTML colors (#FFFFFF format)
			return new Color(Integer.parseInt(color.substring(1), 16));
		}else if(color.trim().startsWith("rgb")){
			// HTML colors (rgb(255, 255, 255) format)
			String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
			String rgb[] = values.split(",");
			return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()), Integer.parseInt(rgb[2].trim()));
		}else{
			// Colors by name
			if(color.equalsIgnoreCase("black")) return Color.black;
			if(color.equalsIgnoreCase("grey")) return Color.gray;
			if(color.equalsIgnoreCase("yellow")) return Color.yellow;
			if(color.equalsIgnoreCase("green")) return Color.green;
			if(color.equalsIgnoreCase("blue")) return Color.blue;
			if(color.equalsIgnoreCase("red")) return Color.red;
			if(color.equalsIgnoreCase("orange")) return Color.orange;
			if(color.equalsIgnoreCase("cyan")) return Color.cyan;
			if(color.equalsIgnoreCase("magenta")) return Color.magenta;
			if(color.equalsIgnoreCase("darkgray")) return Color.darkGray;
			if(color.equalsIgnoreCase("lightgray")) return Color.lightGray;
			if(color.equalsIgnoreCase("pink")) return Color.pink;
			if(color.equalsIgnoreCase("white")) return Color.white;
		}
	}
	log.info("Unable to parse body background-color (color:" + color+"). Assuming white.");
	return Color.white;
}
 
Example 11
public static Color parseColor(String color) {
	if(color != null) {
		if(color.trim().startsWith("#")){
			// HTML colors (#FFFFFF format)
			return new Color(Integer.parseInt(color.substring(1), 16));
		}else if(color.trim().startsWith("rgb")){
			// HTML colors (rgb(255, 255, 255) format)
			String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
			String rgb[] = values.split(",");
			return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()), Integer.parseInt(rgb[2].trim()));
		}else{
			// Colors by name
			if(color.equalsIgnoreCase("black")) return Color.black;
			if(color.equalsIgnoreCase("grey")) return Color.gray;
			if(color.equalsIgnoreCase("yellow")) return Color.yellow;
			if(color.equalsIgnoreCase("green")) return Color.green;
			if(color.equalsIgnoreCase("blue")) return Color.blue;
			if(color.equalsIgnoreCase("red")) return Color.red;
			if(color.equalsIgnoreCase("orange")) return Color.orange;
			if(color.equalsIgnoreCase("cyan")) return Color.cyan;
			if(color.equalsIgnoreCase("magenta")) return Color.magenta;
			if(color.equalsIgnoreCase("darkgray")) return Color.darkGray;
			if(color.equalsIgnoreCase("lightgray")) return Color.lightGray;
			if(color.equalsIgnoreCase("pink")) return Color.pink;
			if(color.equalsIgnoreCase("white")) return Color.white;
		}
	}
	log.info("Unable to parse body background-color (color:" + color+"). Assuming white.");
	return Color.white;
}
 
Example 12
public OtherColorTableModel(java.util.Locale p_locale)
{
    super(1, p_locale);
    data[0] = new Color [ColumnNames.values().length];
    Object[] curr_row = data[0];
    curr_row[ColumnNames.BACKGROUND.ordinal()] = new Color(70, 70, 70);
    curr_row[ColumnNames.HIGHLIGHT.ordinal()] = Color.white;
    curr_row[ColumnNames.INCOMPLETES.ordinal()] = Color.white;
    curr_row[ColumnNames.OUTLINE.ordinal()] = new Color(100, 150, 255);
    curr_row[ColumnNames.VIOLATIONS.ordinal()] = Color.magenta;
    curr_row[ColumnNames.COMPONENT_FRONT.ordinal()] = Color.blue;
    curr_row[ColumnNames.COMPONENT_BACK.ordinal()] = Color.red;
    curr_row[ColumnNames.LENGTH_MATCHING_AREA.ordinal()] = Color.green;
}
 
Example 13
public OtherColorTableModel(java.util.Locale p_locale)
{
    super(1, p_locale);
    data[0] = new Color [ColumnNames.values().length];
    Object[] curr_row = data[0];
    curr_row[ColumnNames.BACKGROUND.ordinal()] = new Color(70, 70, 70);
    curr_row[ColumnNames.HIGHLIGHT.ordinal()] = Color.white;
    curr_row[ColumnNames.INCOMPLETES.ordinal()] = Color.white;
    curr_row[ColumnNames.OUTLINE.ordinal()] = new Color(100, 150, 255);
    curr_row[ColumnNames.VIOLATIONS.ordinal()] = Color.magenta;
    curr_row[ColumnNames.COMPONENT_FRONT.ordinal()] = Color.blue;
    curr_row[ColumnNames.COMPONENT_BACK.ordinal()] = Color.red;
    curr_row[ColumnNames.LENGTH_MATCHING_AREA.ordinal()] = Color.green;
}
 
Example 14
private static Color parseColor(String color) {
	if(color != null) {
		if(color.trim().startsWith("#")){
			// HTML colors (#FFFFFF format)
			return new Color(Integer.parseInt(color.substring(1), 16));
		}else if(color.trim().startsWith("rgb")){
			// HTML colors (rgb(255, 255, 255) format)
			String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
			String rgb[] = values.split(",");
			return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()), Integer.parseInt(rgb[2].trim()));
		}else{
			// Colors by name
			if(color.equalsIgnoreCase("black")) return Color.black;
			if(color.equalsIgnoreCase("grey")) return Color.gray;
			if(color.equalsIgnoreCase("yellow")) return Color.yellow;
			if(color.equalsIgnoreCase("green")) return Color.green;
			if(color.equalsIgnoreCase("blue")) return Color.blue;
			if(color.equalsIgnoreCase("red")) return Color.red;
			if(color.equalsIgnoreCase("orange")) return Color.orange;
			if(color.equalsIgnoreCase("cyan")) return Color.cyan;
			if(color.equalsIgnoreCase("magenta")) return Color.magenta;
			if(color.equalsIgnoreCase("darkgray")) return Color.darkGray;
			if(color.equalsIgnoreCase("lightgray")) return Color.lightGray;
			if(color.equalsIgnoreCase("pink")) return Color.pink;
			if(color.equalsIgnoreCase("white")) return Color.white;
		}
	}
	log.info("Unable to parse body background-color (color:" + color+"). Assuming white.");
	return Color.white;
}
 
Example 15
public static Color parseColor(String color) {
	if(color != null) {
		if(color.trim().startsWith("#")){
			// HTML colors (#FFFFFF format)
			return new Color(Integer.parseInt(color.substring(1), 16));
		}else if(color.trim().startsWith("rgb")){
			// HTML colors (rgb(255, 255, 255) format)
			String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
			String rgb[] = values.split(",");
			return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()), Integer.parseInt(rgb[2].trim()));
		}else{
			// Colors by name
			if(color.equalsIgnoreCase("black")) return Color.black;
			if(color.equalsIgnoreCase("grey")) return Color.gray;
			if(color.equalsIgnoreCase("yellow")) return Color.yellow;
			if(color.equalsIgnoreCase("green")) return Color.green;
			if(color.equalsIgnoreCase("blue")) return Color.blue;
			if(color.equalsIgnoreCase("red")) return Color.red;
			if(color.equalsIgnoreCase("orange")) return Color.orange;
			if(color.equalsIgnoreCase("cyan")) return Color.cyan;
			if(color.equalsIgnoreCase("magenta")) return Color.magenta;
			if(color.equalsIgnoreCase("darkgray")) return Color.darkGray;
			if(color.equalsIgnoreCase("lightgray")) return Color.lightGray;
			if(color.equalsIgnoreCase("pink")) return Color.pink;
			if(color.equalsIgnoreCase("white")) return Color.white;
		}
	}
	log.info("Unable to parse body background-color (color:" + color+"). Assuming white.");
	return Color.white;
}
 
Example 16
Source Project: osp   File: ConstantParser.java    License: GNU General Public License v3.0 4 votes vote down vote up
static public Value colorConstant(String _value) {
  if(_value.indexOf(',')>=0) {                               // format is red,green,blue
    try {
      StringTokenizer t = new StringTokenizer(_value, ":,"); //$NON-NLS-1$
      int r = Integer.parseInt(t.nextToken());
      int g = Integer.parseInt(t.nextToken());
      int b = Integer.parseInt(t.nextToken());
      int alpha;
      if(t.hasMoreTokens()) {
        alpha = Integer.parseInt(t.nextToken());
      } else {
        alpha = 255;
      }
      if(r<0) {
        r = 0;
      } else if(r>255) {
        r = 255;
      }
      if(g<0) {
        g = 0;
      } else if(g>255) {
        g = 255;
      }
      if(b<0) {
        b = 0;
      } else if(b>255) {
        b = 255;
      }
      if(alpha<0) {
        alpha = 0;
      } else if(alpha>255) {
        alpha = 255;
      }
      return new ObjectValue(new Color(r, g, b, alpha));
    } catch(Exception exc) {
      exc.printStackTrace();
      return null;
    }
  }
  if(_value.equals("null")||_value.equals("none")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(NULL_COLOR);
  }
  if(_value.equals("black")||_value.equals("Color.black")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.black);
  }
  if(_value.equals("blue")||_value.equals("Color.blue")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.blue);
  }
  if(_value.equals("cyan")||_value.equals("Color.cyan")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.cyan);
  }
  if(_value.equals("darkGray")||_value.equals("Color.darkGray")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.darkGray);
  }
  if(_value.equals("gray")||_value.equals("Color.gray")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.gray);
  }
  if(_value.equals("green")||_value.equals("Color.green")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.green);
  }
  if(_value.equals("lightGray")||_value.equals("Color.lightGray")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.lightGray);
  }
  if(_value.equals("magenta")||_value.equals("Color.magenta")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.magenta);
  }
  if(_value.equals("orange")||_value.equals("Color.orange")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.orange);
  }
  if(_value.equals("pink")||_value.equals("Color.pink")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.pink);
  }
  if(_value.equals("red")||_value.equals("Color.red")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.red);
  }
  if(_value.equals("white")||_value.equals("Color.white")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.white);
  }
  if(_value.equals("yellow")||_value.equals("Color.yellow")) { //$NON-NLS-1$ //$NON-NLS-2$
    return new ObjectValue(Color.yellow);
  }
  return null; // Not a valid constant
}
 
Example 17
Source Project: VanetSim   File: Cluster.java    License: GNU General Public License v3.0 4 votes vote down vote up
public boolean fillCluster(String filePath, String clusterID){		
	String searchKey = "@data";
	
	clusterID_ = clusterID;
	
	try{
		// Open the file that is the first 
		// command line parameter
		FileInputStream fstream = new FileInputStream(filePath);
		// Get the object of DataInputStream
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String strLine;
		String[] splitLine;
		//Read file line By line
		
		boolean found = false;
		
		while ((strLine = br.readLine()) != null) {
			if(strLine.equals(searchKey)) found = true;
			
			if(found){			
				//System.out.println(strLine):

				
			
				splitLine = strLine.split(",");
				
				if(splitLine[splitLine.length-1].equals("cluster" + clusterID_)){
					size_++;
					eventType_ = splitLine[1];
					
					if(eventType_.equals("HUANG_PCN")) clusterColor = Color.green;
					if(eventType_.equals("HUANG_EEBL")) clusterColor = Color.blue;
					if(eventType_.equals("PCN_FORWARD")) clusterColor = Color.pink;
					if(eventType_.equals("HUANG_RHCN")) clusterColor = Color.gray;
					if(eventType_.equals("EVA_FORWARD")) clusterColor = Color.cyan;
					if(eventType_.equals("HUANG_EVA")) clusterColor = Color.magenta;
					
					xCoords_.add(Integer.parseInt(splitLine[2]));
					yCoords_.add(Integer.parseInt(splitLine[3]));
					if(Integer.parseInt(splitLine[2]) > maxX_) maxX_ = Integer.parseInt(splitLine[2]);
					if(Integer.parseInt(splitLine[2]) < minX_) minX_ = Integer.parseInt(splitLine[2]);
					
					if(Integer.parseInt(splitLine[3]) > maxY_) maxY_ = Integer.parseInt(splitLine[3]);
					if(Integer.parseInt(splitLine[3]) < minY_) minY_ = Integer.parseInt(splitLine[3]);
				}
				

			}	
		}
		  
		//Close the input stream
		in.close();
	}catch (Exception e){//Catch exception if any
		System.err.println("Error: " + e.getMessage());
	}
	
	
	if(size_ > 0) return true;
	else return false;
}
 
Example 18
Source Project: netbeans   File: NbDocument$Colors.java    License: Apache License 2.0 4 votes vote down vote up
public Color getCurrent() {
    return Color.magenta;
}
 
Example 19
protected final void loadColors() {

		colorBlue = new Color(140, 120, 255);
		colorTurq = new Color(0, 240, 255);
		colorRed = Color.red;
		colorWhite = Color.white;
		colorYellow = Color.yellow;
		colorGreen = Color.green;
		colorPink = Color.magenta;
		colorGUIField = Color.white;
		colorSep = Color.white;
		colorHexAttr = Color.white;

		if (cfg_guiInterface)
			colorBg = Color.lightGray;
		else
			colorBg = Color.black;

		colorCursor = Color.white;

		if (!config.isPropertyExists("colorBg"))
			setProperty("colorBg", Integer.toString(colorBg.getRGB()));
		else {
			colorBg = getColorProperty("colorBg");
		}
		gui.setBackground(colorBg);

		if (!config.isPropertyExists("colorBlue"))
			setProperty("colorBlue", Integer.toString(colorBlue.getRGB()));
		else
			colorBlue = getColorProperty("colorBlue");

		if (!config.isPropertyExists("colorTurq"))
			setProperty("colorTurq", Integer.toString(colorTurq.getRGB()));
		else
			colorTurq = getColorProperty("colorTurq");

		if (!config.isPropertyExists("colorRed"))
			setProperty("colorRed", Integer.toString(colorRed.getRGB()));
		else
			colorRed = getColorProperty("colorRed");

		if (!config.isPropertyExists("colorWhite"))
			setProperty("colorWhite", Integer.toString(colorWhite.getRGB()));
		else
			colorWhite = getColorProperty("colorWhite");

		if (!config.isPropertyExists("colorYellow"))
			setProperty("colorYellow", Integer.toString(colorYellow.getRGB()));
		else
			colorYellow = getColorProperty("colorYellow");

		if (!config.isPropertyExists("colorGreen"))
			setProperty("colorGreen", Integer.toString(colorGreen.getRGB()));
		else
			colorGreen = getColorProperty("colorGreen");

		if (!config.isPropertyExists("colorPink"))
			setProperty("colorPink", Integer.toString(colorPink.getRGB()));
		else
			colorPink = getColorProperty("colorPink");

		if (!config.isPropertyExists("colorGUIField"))
			setProperty("colorGUIField", Integer.toString(colorGUIField
					.getRGB()));
		else
			colorGUIField = getColorProperty("colorGUIField");

		if (!config.isPropertyExists("colorCursor"))
			setProperty("colorCursor", Integer.toString(colorCursor.getRGB()));
		else
			colorCursor = getColorProperty("colorCursor");

		if (!config.isPropertyExists("colorSep")) {
			colorSep = colorWhite;
			setProperty("colorSep", Integer.toString(colorSep.getRGB()));
		} else
			colorSep = getColorProperty("colorSep");

		if (!config.isPropertyExists("colorHexAttr")) {
			colorHexAttr = colorWhite;
			setProperty("colorHexAttr", Integer.toString(colorHexAttr.getRGB()));
		} else
			colorHexAttr = getColorProperty("colorHexAttr");

	}
 
Example 20
Source Project: ensemble-clustering   File: TestDPMeans.java    License: MIT License 4 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	int k = 5;
	
	try {
		FileUtils.deleteDirectory( new File("output/clusters") );
		FileUtils.deleteDirectory( new File("output/centroids") );
	} catch (IOException e1) { /* ignore (*/ }		
	
	genTestData(k);
	
	JavaSparkContext sc = new JavaSparkContext("local", "OculusML");  
	SparkDataSet ds = new SparkDataSet(sc);
	ds.load("test.txt", new InstanceParser() );

	DPMeansClusterer clusterer = new DPMeansClusterer(80, 10, 0.001);
	clusterer.setOutputPaths("output/centroids", "output/clusters");
	
	clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0));
	
	clusterer.doCluster(ds);
	
	try {
		final List<double[]> instances = readInstances();
		
		final Color[] colors = {Color.red, 
				Color.blue, 
				Color.green, 
				Color.magenta, 
				Color.yellow, 
				Color.black, 
				Color.orange, 
				Color.cyan,
				Color.darkGray,
				Color.white};
		
		TestDPMeans t = new TestDPMeans();
        t.add(new JComponent() {
			private static final long serialVersionUID = 7920802321066846416L;

			public void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                    RenderingHints.VALUE_ANTIALIAS_ON);
               
                for (double[] inst : instances) {
                	int color = (int)inst[0];
                	g.setColor ( colors[color] );
                	
                	Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5);
                	g2.draw(l);
                }
            }
        });

        t.setDefaultCloseOperation(EXIT_ON_CLOSE);
        t.setSize(400, 400);
        t.setVisible(true);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}