Example usage for java.awt Color Color

List of usage examples for java.awt Color Color

Introduction

In this page you can find the example usage for java.awt Color Color.

Prototype

public Color(int rgb) 

Source Link

Document

Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.

Usage

From source file:com.kennycason.kumo.LayeredWordCloudITest.java

@Test
public void layeredExample() throws IOException {
    final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
    frequencyAnalyzer.setWordFrequenciesToReturn(300);
    frequencyAnalyzer.setMinWordLength(5);
    frequencyAnalyzer.setStopWords(loadStopWords());

    final List<WordFrequency> wordFrequencies = frequencyAnalyzer
            .load(getInputStream("text/new_york_positive.txt"));
    final List<WordFrequency> wordFrequencies2 = frequencyAnalyzer
            .load(getInputStream("text/new_york_negative.txt"));
    final Dimension dimension = new Dimension(600, 386);
    final LayeredWordCloud layeredWordCloud = new LayeredWordCloud(2, dimension, CollisionMode.PIXEL_PERFECT);

    layeredWordCloud.setPadding(0, 1);//  www  .jav  a  2 s . c o  m
    layeredWordCloud.setPadding(1, 1);

    layeredWordCloud.setFontOptions(0, new KumoFont("LICENSE PLATE", FontWeight.BOLD));
    layeredWordCloud.setFontOptions(1, new KumoFont("Comic Sans MS", FontWeight.BOLD));

    layeredWordCloud.setBackground(0, new PixelBoundryBackground(getInputStream("backgrounds/cloud_bg.bmp")));
    layeredWordCloud.setBackground(1, new PixelBoundryBackground(getInputStream("backgrounds/cloud_fg.bmp")));

    layeredWordCloud.setColorPalette(0,
            new ColorPalette(new Color(0xABEDFF), new Color(0x82E4FF), new Color(0x55D6FA)));
    layeredWordCloud.setColorPalette(1,
            new ColorPalette(new Color(0xFFFFFF), new Color(0xDCDDDE), new Color(0xCCCCCC)));

    layeredWordCloud.setFontScalar(0, new SqrtFontScalar(10, 40));
    layeredWordCloud.setFontScalar(1, new SqrtFontScalar(10, 40));

    final long startTime = System.currentTimeMillis();
    layeredWordCloud.build(0, wordFrequencies);
    layeredWordCloud.build(1, wordFrequencies2);
    LOGGER.info("Took " + (System.currentTimeMillis() - startTime) + "ms to build");
    layeredWordCloud.writeToFile("output/layered_word_cloud.png");
}

From source file:baocaoxla.xuly_compare.java

public int intersection(BufferedImage image, BufferedImage imgcompare) {
    int[] his = new int[256];
    int[] his1 = new int[256];

    for (int i = 0; i < 256; i++) {
        his[i] = 0;/*from w  w  w .  j a v a  2  s . co  m*/
        his1[i] = 0;

    }
    int width = image.getWidth();
    int height = image.getHeight();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            Color c = new Color(image.getRGB(j, i));
            his[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++;

        }
    }
    int width1 = imgcompare.getWidth();
    int height1 = imgcompare.getHeight();
    for (int i = 0; i < height1; i++) {
        for (int j = 0; j < width1; j++) {
            Color c = new Color(imgcompare.getRGB(j, i));
            his1[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++;
        }
    }
    double summin = 0;
    double sumhis = 0;

    for (int i = 0; i < 256; i++) {
        summin = summin + Math.min(his[i], his1[i]);
        sumhis = sumhis + his[i];
    }
    int percentred = (int) ((summin / sumhis) * 100);
    return percentred;
}

From source file:br.prof.salesfilho.oci.image.ImageProcessor.java

public double[] getGreen() {
    int[] colors = new int[this.image.getWidth() * this.image.getHeight()];
    this.image.getRGB(0, 0, this.image.getWidth(), this.image.getHeight(), colors, 0, this.image.getWidth());

    double[] green = new double[colors.length];

    for (int i = 0; i < colors.length; i++) {
        Color color = new Color(colors[i]);
        int rgb = color.getRGB();
        int g = (rgb >> 8) & 0xFF;
        green[i] = (double) g;
    }/*from  w ww  .  j  a  v a  2s.  c  o  m*/
    return green;
}

From source file:edu.kit.dama.ui.components.TextImage.java

/**
 * Protected constructor./* w ww . j  a  v a 2s . c  o  m*/
 *
 * @param pText The test the image should represent.
 */
protected TextImage(String pText) {
    if (pText != null) {
        text = pText;
        color = new Color(colorGen.getColor(text));
    }
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrProjectPanelVisual2.java

public InitializrProjectPanelVisual2() {
    initComponents();/*from  w  ww  .  j a  v a2  s  .  c o  m*/
    // setup key listener on search field linked to dependencies panel
    FilterFieldListener ffl = new FilterFieldListener(pBootDependencies);
    txFilter.addKeyListener(ffl);
    txFilter.getDocument().addDocumentListener(ffl);
    // fix white area showing when the scroller is wider than the dependencies panel on some LAFs
    // for some reasons setting the UIManager color directly doesn't work it must be copied in a new Color object
    final Color cr = UIManager.getColor("Panel.background");
    scroller.getViewport().setBackground(new Color(cr.getRGB()));
}

From source file:gr.iti.mklab.reveal.forensics.maps.dwnoisevar.DWNoiseVarExtractor.java

public void getNoiseMap() throws IOException {

    BufferedImage img = inputImage;

    int imWidth, imHeight;
    if (img.getWidth() % 2 == 0) {
        imWidth = img.getWidth();//from w  w  w .j  ava 2 s . c  o m
    } else {
        imWidth = (img.getWidth() - 1);
    }
    if (img.getHeight() % 2 == 0) {
        imHeight = img.getHeight();
    } else {
        imHeight = (img.getHeight() - 1);
    }

    int columnFilterScale = (int) (Math.log(imHeight) / Math.log(2)) - 1;
    int rowFilterScale = (int) (Math.log(imWidth) / Math.log(2)) - 1;

    double[][] imgYAsArray = new double[imWidth][imHeight];
    double[][] filteredImgYAsArray = new double[imWidth][imHeight / 2];
    double[][] doubleFilteredImgYAsArray = new double[imWidth / 2][imHeight / 2];
    double[] imgColumn, imgRow;
    Color tmpcolor;
    double R, G, B;

    for (int ii = 0; ii < imWidth; ii++) {
        for (int jj = 0; jj < imHeight; jj++) {
            tmpcolor = new Color(img.getRGB(ii, jj));
            R = tmpcolor.getRed();
            G = tmpcolor.getGreen();
            B = tmpcolor.getBlue();
            imgYAsArray[ii][jj] = 0.2989 * R + 0.5870 * G + 0.1140 * B;
        }
    }

    double[] waveletColumn;
    RealMatrix rm = new Array2DRowRealMatrix(imgYAsArray);
    for (int ii = 0; ii < imWidth; ii++) {
        try {
            imgColumn = new double[imHeight];
            imgColumn = rm.getRow(ii);
            //Long startTime1 = System.currentTimeMillis();  
            waveletColumn = DWT.transform(imgColumn, Wavelet.Daubechies, 8, columnFilterScale,
                    DWT.Direction.forward);
            System.arraycopy(waveletColumn, imHeight / 2, filteredImgYAsArray[ii], 0, imHeight / 2);
        } catch (Exception ex) {
            Logger.getLogger(DWNoiseVarExtractor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    double[] waveletRow;
    RealMatrix rm2 = new Array2DRowRealMatrix(filteredImgYAsArray);
    for (int jj = 0; jj < imHeight / 2; jj++) {
        try {
            imgRow = new double[imWidth];
            imgRow = rm2.getColumn(jj);
            waveletRow = DWT.transform(imgRow, Wavelet.Daubechies, 8, rowFilterScale, DWT.Direction.forward);
            for (int ii = 0; ii < imWidth / 2; ii++) {
                doubleFilteredImgYAsArray[ii][jj] = waveletRow[ii + imWidth / 2];
            }
        } catch (Exception ex) {
            Logger.getLogger(DWNoiseVarExtractor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    int blockSize = 8;
    double[][] blockNoiseVar = Util.blockNoiseVar(doubleFilteredImgYAsArray, blockSize);

    int medianFilterSize = 7;
    if (medianFilterSize > blockNoiseVar.length) {
        medianFilterSize = blockNoiseVar.length - 1;
    }
    if (medianFilterSize > blockNoiseVar[0].length) {
        medianFilterSize = blockNoiseVar[0].length - 1;
    }
    if (medianFilterSize < 5) {
        minNoiseValue = 0;
        maxNoiseValue = 0;
        noiseMap = new float[1][1];
        noiseMap[0][0] = 0;
        double[][] artificialOutput = new double[1][1];
        artificialOutput[0][0] = 0;
        BufferedImage outputImage = Util.visualizeWithJet(artificialOutput);
        displaySurface = outputImage;
        return;
    }

    float[][] outBlockMap = Util.medianFilterSingleChannelImage(blockNoiseVar, medianFilterSize);

    minNoiseValue = Util.minDouble2DArray(outBlockMap);
    maxNoiseValue = Util.maxDouble2DArray(outBlockMap);
    noiseMap = outBlockMap;
    double[][] normalizedMap = Util.normalizeIm(outBlockMap);
    BufferedImage outputImage = Util.visualizeWithJet(normalizedMap);
    // output
    displaySurface = outputImage;
}

From source file:com.floreantpos.model.MenuGroup.java

@XmlTransient
public Color getTextColor() {
    if (textColor != null) {
        return textColor;
    }/*w w  w  .  j av  a 2s. com*/

    if (getTextColorCode() == null) {
        return null;
    }

    return textColor = new Color(getTextColorCode());
}

From source file:com.floreantpos.model.MenuCategory.java

@XmlTransient
public Color getTextColor() {
    if (textColor != null) {
        return textColor;
    }/*from   www . ja va 2 s  . c om*/

    if (getTextColorCode() == null || getTextColorCode() == 0) {
        return null;
    }

    return textColor = new Color(getTextColorCode());
}

From source file:de.erdesignerng.model.serializer.xml10.XMLSubjectAreaSerializer.java

@Override
public void deserialize(Model aModel, Document aDocument) {

    NodeList theElements = aDocument.getElementsByTagName(SUBJECTAREA);
    for (int i = 0; i < theElements.getLength(); i++) {
        Element theElement = (Element) theElements.item(i);

        SubjectArea theSubjectArea = new SubjectArea();
        deserializeProperties(theElement, theSubjectArea);

        theSubjectArea.setColor(new Color(Integer.parseInt(theElement.getAttribute(COLOR))));

        NodeList theTables = theElement.getElementsByTagName(ITEM);
        for (int j = 0; j < theTables.getLength(); j++) {

            Element theItemElement = (Element) theTables.item(j);
            String theTableId = theItemElement.getAttribute(TABLEREFID);
            String theCommentId = theItemElement.getAttribute(COMMENTREFID);

            if (!StringUtils.isEmpty(theTableId)) {
                Table theTable = aModel.getTables().findBySystemId(theTableId);
                if (theTable == null) {
                    throw new IllegalArgumentException("Cannot find table with id " + theTableId);
                }/*from ww  w .java2  s .  c om*/

                theSubjectArea.getTables().add(theTable);
            }

            if (!StringUtils.isEmpty(theCommentId)) {
                Comment theComment = aModel.getComments().findBySystemId(theCommentId);
                if (theComment == null) {
                    throw new IllegalArgumentException("Cannot find comment with id " + theCommentId);
                }

                theSubjectArea.getComments().add(theComment);
            }
        }

        aModel.getSubjectAreas().add(theSubjectArea);
    }

}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

@Override
protected JFreeChart createChart() {
    // create the chart...
    pieDataSet = createDataset();/*from  www  .jav a  2 s.  c  o m*/
    final JFreeChart chart = ChartFactory.createPieChart3D("", // chart
            // title
            pieDataSet, // data
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.getTitle().setPaint(new Color(0x5E5E5E));
    chart.setBorderVisible(false);
    // set the background color for the chart...
    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setStartAngle(290);
    plot.setBackgroundPaint(Color.white);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new JFreeChartLabelCustom());

    final List keys = pieDataSet.getKeys();
    for (int i = 0; i < keys.size(); i++) {
        final Comparable key = (Comparable) keys.get(i);
        plot.setSectionPaint(key, Color.decode(
                "0x" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length]));
    }
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}