Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

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

Prototype

Color YELLOW

To view the source code for java.awt Color YELLOW.

Click Source Link

Document

The color yellow.

Usage

From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java

public SourceCodeView(IResourceResolver resourceResolver, IWorkspace workspace,
        NavigationHistory navigationHistory, boolean isEditable) {
    if (workspace == null) {
        throw new IllegalArgumentException("workspace must not be null");
    }/*from ww  w.j a  va2 s.c  o  m*/
    if (resourceResolver == null) {
        throw new IllegalArgumentException("resourceResolver must not be NULL.");
    }
    this.navigationHistory = navigationHistory;
    this.resourceResolver = resourceResolver;
    this.editable = isEditable;
    this.workspace = workspace;
    defaultStyle = new SimpleAttributeSet();
    errorStyle = createStyle(Color.RED);
    registerStyle = createStyle(Color.ORANGE);
    commentStyle = createStyle(Color.WHITE);
    macroDefinitionStyle = createStyle(Color.YELLOW);
    macroInvocationStyle = createStyle(Color.YELLOW);
    instructionStyle = createStyle(new Color(50, 186, 223));
    labelStyle = createStyle(new Color(237, 237, 81));
    preProcessorStyle = createStyle(new Color(200, 200, 200));
    workspace.addWorkspaceListener(workspaceListener);
    navigationHistory.addListener(navigationHistoryListener);
}

From source file:com.josue.tileset.editor.Editor.java

private void mountButtons(List<Tile> tiles, int cols, int rows) {

    imagePanel.removeAll();/*from w w  w.j  a  v  a2  s . c  om*/
    if (animatedPerformer != null) {
        animatedPerformer.stop();
        animatedPerformer = null;
    }

    imagePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    Dimension dimension = new Dimension(cols * TILE_SIZE, rows * TILE_SIZE);

    for (Tile tile : tiles) {
        final JLabel tileLabel = new JLabel();

        tileLabel.setIcon(new ImageIcon(tile.getImage()));
        Dimension labelDimension = new Dimension(TILE_SIZE, TILE_SIZE);
        tileLabel.setMinimumSize(labelDimension);
        tileLabel.setMaximumSize(labelDimension);
        tileLabel.setPreferredSize(labelDimension);
        tileLabel.setSize(labelDimension);
        tileLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                if (SwingUtilities.isRightMouseButton(evt)) {//select animated sequence

                    if (animatedAction.isSelected()) {
                        addAnimatedTile(tile);
                    } else {
                        addLightSourceTile(tile);
                    }

                } else {

                    if (animatedPerformer != null) {
                        animatedPerformer.stop();
                    }
                    Iterator<JLabel> iterator = tileLabels.values().iterator();
                    while (iterator.hasNext()) {
                        JLabel next = iterator.next();
                        next.revalidate();
                    }
                    imagePanel.repaint();
                    for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) {
                        Tile key = entry.getKey();
                        JLabel value = entry.getValue();
                        value.setBorder(null); //clear borders
                    }

                    selectedTile = tile;//this isolate for the next operations
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));

                    previewLabel.setIcon(new ImageIcon(tile.getImage()));
                    animatedTb.setSelected(selectedTile.isAnimated());
                    lightTb.setSelected(selectedTile.isLight());
                    solidTb.setSelected(selectedTile.isSolid());

                    if (tile.isAnimated()) {

                        for (Integer animatesTileOffset : selectedTile.getAnimation().getAnimatedSequence()) { //display animated borders
                            for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) {
                                Tile key = entry.getKey();
                                JLabel value = entry.getValue();
                                if (key.getId() == selectedTile.getId() + animatesTileOffset) {
                                    value.setBorder(new LineBorder(Color.BLUE, 2));
                                }
                            }

                        }

                        animatedPerformer = new Timer(
                                (int) (selectedTile.getAnimation().getAnimationInterval()),
                                new TileAnimator(selectedTile, previewLabel, loadedTiles));
                        animatedPerformer.start();
                    }
                    if (selectedTile.isLight()) {//light color has preference
                        for (Tile tile : tiles) {
                            if (tile.getId() == selectedTile.getLightTileId()) {
                                JLabel found = tileLabels.get(tile);
                                found.setBorder(new LineBorder(Color.YELLOW, 2));
                                break;
                            }
                        }

                    }
                }
            }

            @Override
            public void mouseExited(MouseEvent e) {
                if (selectedTile != null && selectedTile.getAnimation() != null && selectedTile.getAnimation()
                        .getAnimatedSequence().contains(tile.getId() - selectedTile.getId())) {
                    tileLabel.setBorder(new LineBorder(Color.BLUE, 2));
                } else if (selectedTile != null && selectedTile.isLight()
                        && selectedTile.getLightTileId() == tile.getId()) {
                    tileLabel.setBorder(new LineBorder(Color.YELLOW, 2));
                } else if (selectedTile != null) {
                    JLabel get = tileLabels.get(selectedTile);
                    if (!get.equals(tileLabel)) { //keep the red border if is the selected
                        tileLabel.setBorder(null);
                    }
                } else {
                    tileLabel.setBorder(null);
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                if (selectedTile != null && selectedTile.getAnimation() != null
                        && !selectedTile.getAnimation().getAnimatedSequence()
                                .contains(tile.getId() - selectedTile.getId())
                        && tile.getLight() != null && tile.getLight().getLightTileOffset() != 0) {
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));
                } else if (selectedTile == null) {
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));
                }
            }
        });
        tileLabels.put(tile, tileLabel);
        imagePanel.add(tileLabel);
    }

    imagePanel.setMaximumSize(dimension);
    imagePanel.setMinimumSize(dimension);
    imagePanel.setPreferredSize(dimension);
    imagePanel.revalidate();
    imagePanel.repaint();
    this.pack();
}

From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java

protected void doGraph() {
    graphPanel.removeAll();/*w ww .  j ava  2  s.  c  o  m*/
    ////////System.out.println("in doGraph");
    //graphPanel.add(description, BorderLayout.SOUTH);
    JFreeChart scatterChart = null;
    ChartPanel chartPanel1 = null;
    ChartPanel chartPanel2 = null;
    Chart chartFactory = new Chart();
    String lineType = "excludesZeroNoShape";
    /*
          double[] survivalTimePlot = new double[plotSize];
          double[] survivalRatePlot = new double[plotSize];
          //////////System.out.println("doGraph survivalTimePlot.length = " + survivalTimePlot.length);
          //////////System.out.println("doGraph survivalRatePlot.length = " + survivalRatePlot.length);
          int newIndex = 0;
          for (int i = 0; i < survivalRate.length; i++) {
             for (int j = 0; j < survivalRate[i].length; j++) {
    survivalTimePlot[newIndex] = survivalTime[i][j];
    survivalRatePlot[newIndex] = survivalRate[i][j];
    newIndex++;
             }
            
          }
    */
    /*
            
          double[][] survivalTimePlot = new double[survivalTime.length][];
          double[][] survivalRatePlot = new double[survivalRate.length][];
          // create the first point (time = 0, rate = 1)
          for (int i = 0; i < survivalTime.length; i++) {
             survivalTimePlot[i] = new double[survivalTime[i].length + 1];
             survivalRatePlot[i] = new double[survivalRate[i].length + 1];
             survivalTimePlot[i][0] = 0;
             survivalRatePlot[i][0] = 1;
             for (int j = 1; j < survivalTimePlot[i].length; j++) {
    survivalTimePlot[i][j] = survivalTime[i][j - 1];
    survivalRatePlot[i][j] = survivalRate[i][j - 1];
             }
          }
    */
    boolean useCI = true; // whether to plot the confidence interval.
    ////////System.out.println("useCI = " + useCI);
    double[][] survivalTimePlot = new double[survivalTime.length][];
    double[][] survivalRatePlot = new double[survivalRate.length][];
    double[][] survivalRateUpperCIPlot = new double[survivalRate.length][];
    double[][] survivalRateLowerCIPlot = new double[survivalRate.length][];

    // create the first point (time = 0, rate = 1)
    double tempTime = 0, tempRate = 0, tempRateUpperCI = 0, tempRateLowerCI = 0;
    int increment = 2;
    int arrayLength = 0;
    int k = 0; // index for survivalTime array, not for survivalTimePlot.
    for (int i = 0; i < survivalTime.length; i++) {
        arrayLength = 2 * survivalRate[i].length + increment;
        k = 0;
        // why add 2? one for the initial point, one for the last point.
        survivalTimePlot[i] = new double[arrayLength];
        survivalRatePlot[i] = new double[arrayLength];

        survivalRateUpperCIPlot[i] = new double[arrayLength];
        survivalRateLowerCIPlot[i] = new double[arrayLength];

        survivalTimePlot[i][0] = 0;
        survivalRatePlot[i][0] = 1;

        survivalRateUpperCIPlot[i][0] = 1;
        survivalRateLowerCIPlot[i][0] = 1;
        int j = 1;
        ////////System.out.println(" before loop survivalTimePlot["+i+"].length= " +survivalTimePlot[i].length);
        for (j = 1; j < survivalTimePlot[i].length - 1; j++) {
            //////////System.out.println("j = " + j + " survivalTimePlot["+i+"].length = " + survivalTimePlot[i].length + ", k = " + k);
            ////////System.out.println("in loop j = " + j);
            if (j % 2 == 1) {

                ////////System.out.println("in if j = " + j + ", k = " + k);
                survivalTimePlot[i][j] = survivalTime[i][k];
                survivalRatePlot[i][j] = survivalRatePlot[i][j - 1];
                survivalRateUpperCIPlot[i][j] = survivalRateUpperCIPlot[i][j - 1];
                survivalRateLowerCIPlot[i][j] = survivalRateLowerCIPlot[i][j - 1];

                tempTime = survivalTimePlot[i][j];
                tempRate = survivalRatePlot[i][j];
                tempRateUpperCI = survivalRateUpperCIPlot[i][j];
                tempRateLowerCI = survivalRateLowerCIPlot[i][j];

            } else {
                //////////System.out.println("in elsej = " + j);
                survivalTimePlot[i][j] = tempTime;
                survivalRatePlot[i][j] = survivalRate[i][k];
                survivalRateUpperCIPlot[i][j] = upperCI[i][k];
                survivalRateLowerCIPlot[i][j] = lowerCI[i][k];

                k++;

            }
            ////////System.out.println("i = " + i + ", j = " + j + ", k = " + k + ", time["+i+"]["+j+"] = " + survivalTimePlot[i][j] + ". rate["+i+"]["+j+"] = " + survivalRatePlot[i][j]);

        }
        int index = j;//survivalTimePlot[i].length-1;//survivalTimePlot[i].length;
        ////////System.out.println("index = " + index);
        ////////System.out.println("maxTime["+i+"] = " + maxTime[i]);

        survivalTimePlot[i][index] = maxTime[i];

        ////////System.out.println("survivalTimePlot["+i+"]["+index+"] = " + survivalTimePlot[i][index]);

        survivalRatePlot[i][index] = survivalRatePlot[i][index - 1];

        survivalRateUpperCIPlot[i][index] = survivalRateUpperCIPlot[i][index - 1];
        survivalRateLowerCIPlot[i][index] = survivalRateLowerCIPlot[i][index - 1];

    }

    int numberGroups = 0, lineSetCount = 0, tempIndex = 0;
    double[][] finalTimeArray = null;
    double[][] finalRateArray = null;
    String[] finalGroupNames = null;
    int numberOfLines = 0;
    //lineSetCount * groupNames.length;
    Color[] colorArray = null;//new Color[numberOfLines];
    ////////System.out.println("lineSetCount = " + lineSetCount);
    if (useCI) {
        numberGroups = groupNames.length;

        lineSetCount = 3; // use 4 if using censor points.
        tempIndex = 0;
        numberOfLines = lineSetCount * numberGroups;
        finalTimeArray = new double[numberOfLines][];
        finalRateArray = new double[numberOfLines][];
        finalGroupNames = new String[numberOfLines];
        ////////System.out.println("numberOfLines = " + numberOfLines);
        colorArray = new Color[numberOfLines];
        // why 3? one for rate, one for upper CI, one for lower CI.

        for (int i = 0; i < numberGroups; i++) {
            // repeat the same time.
            finalTimeArray[tempIndex] = survivalTimePlot[i];
            finalTimeArray[tempIndex + 1] = survivalTimePlot[i];
            finalTimeArray[tempIndex + 2] = survivalTimePlot[i];
            //finalTimeArray[tempIndex+3] = censoredTime[i];

            finalRateArray[tempIndex] = survivalRatePlot[i];
            finalRateArray[tempIndex + 1] = survivalRateUpperCIPlot[i];
            finalRateArray[tempIndex + 2] = survivalRateLowerCIPlot[i];
            //finalRateArray[tempIndex+3] = censoredRate[i];

            finalGroupNames[tempIndex] = groupNames[i];
            finalGroupNames[tempIndex + 1] = groupNames[i] + " Upper CI";
            finalGroupNames[tempIndex + 2] = groupNames[i] + " Lower CI";
            //finalGroupNames[tempIndex+3] = groupNames[i] + " Censored";
            if (i % 5 == 0) {
                colorArray[tempIndex] = Color.RED;
                colorArray[tempIndex + 1] = Color.PINK;
                colorArray[tempIndex + 2] = Color.PINK;

            } else if (i % 5 == 1) {
                colorArray[tempIndex] = Color.BLUE;
                colorArray[tempIndex + 1] = Color.CYAN;
                colorArray[tempIndex + 2] = Color.CYAN;

            } else if (i % 5 == 2) {
                colorArray[tempIndex] = Color.GRAY;
                colorArray[tempIndex + 1] = Color.LIGHT_GRAY;
                colorArray[tempIndex + 2] = Color.LIGHT_GRAY;

            } else if (i % 5 == 3) {
                colorArray[tempIndex] = Color.MAGENTA;
                colorArray[tempIndex + 1] = Color.PINK;
                colorArray[tempIndex + 2] = Color.PINK;

            } else {
                colorArray[tempIndex] = Color.GREEN;
                colorArray[tempIndex + 1] = Color.YELLOW;
                colorArray[tempIndex + 2] = Color.YELLOW;
            }

            tempIndex += lineSetCount;

        }
    } else {
        numberGroups = groupNames.length;

        lineSetCount = 2;
        tempIndex = 0;
        finalTimeArray = new double[lineSetCount * numberGroups][];
        finalRateArray = new double[lineSetCount * numberGroups][];
        finalGroupNames = new String[lineSetCount * numberGroups];

        // why 3? one for rate, one for upper CI, one for lower CI.

        for (int i = 0; i < numberGroups; i++) {
            // repeat the same time.
            finalTimeArray[tempIndex] = survivalTimePlot[i];
            finalTimeArray[tempIndex + 1] = censoredTime[i];

            finalRateArray[tempIndex] = survivalRatePlot[i];
            finalRateArray[tempIndex + 1] = censoredRate[i];

            finalGroupNames[tempIndex] = groupNames[i];
            //finalGroupNames[tempIndex+1] = groupNames[i] + " Censored";

            tempIndex += lineSetCount;
        }

    }

    //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", groupNames.length, groupNames, survivalTimePlot, survivalRatePlot, lineType);
    //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length, finalGroupNames, finalTimeArray, finalRateArray, lineType); // this one has color.

    //public JFreeChart getLineChart(String title, String xLabel, String yLabel, double[] x, double[] y, Color[] colors,  String other)

    //public JFreeChart getLineChart(String title, String xLabel, String yLabel, int numberOfLines, String[] lineNames, double[][] x, double[][] y, Color[] colors, String other)
    //int numberOfLines = lineSetCount * groupNames.length;
    //Color[] colors = new Color[numberOfLines];

    //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", numberOfLines, finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType);

    scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length,
            finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType); // this one has color.

    //for (int i = 0; i < survivalTime.length; i++) {
    //scatterChart  = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", survivalTimePlot, survivalRatePlot, lineType);
    //}
    scatterChart.setTitle("Expected Survival Times with 95% Confidence Limits");
    chartPanel1 = new ChartPanel(scatterChart, false);
    chartPanel1.setPreferredSize(new Dimension(plotWidth, plotHeight));

    JPanel innerPanel = new JPanel();
    JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    graphPanel.add(graphPane);
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));
    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    innerPanel.add(chartPanel1);

    // Add a second plot without the confidence intervals (confidence limits)
    int lineSetCount1 = lineSetCount - 2;
    int tempIndex1 = 0;
    double[][] finalTimeArray1 = new double[lineSetCount1 * numberGroups][];
    double[][] finalRateArray1 = new double[lineSetCount1 * numberGroups][];
    String[] finalGroupNames1 = new String[lineSetCount1 * numberGroups];
    for (int i = 0; i < numberGroups; i++) {
        // repeat the same time.
        finalTimeArray1[tempIndex1] = survivalTimePlot[i];
        //finalTimeArray1[tempIndex1+1] = censoredTime[i];
        finalRateArray1[tempIndex1] = survivalRatePlot[i];
        //finalRateArray1[tempIndex1+1] = censoredRate[i];
        finalGroupNames1[tempIndex1] = groupNames[i];
        tempIndex1 += lineSetCount1;
    }
    JFreeChart scatterChart1 = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate",
            (lineSetCount1) * groupNames.length, finalGroupNames1, finalTimeArray1, finalRateArray1, colorArray,
            lineType); // this one has color.
    scatterChart1.setTitle("Expected Survival Times (Only)");
    chartPanel2 = new ChartPanel(scatterChart1, false);
    chartPanel2.setPreferredSize(new Dimension(plotWidth, plotHeight));
    innerPanel.add(chartPanel2);

    graphPanel.validate();

}

From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java

/**
 * Update lots of UI components after a change of quantitation event
 *//*from   ww w .j  av a 2  s  .  co m*/
protected void updateUIAfterChange(boolean shouldUpdateTable) {
    QuantEvent quantEvent = quantEvents.get(displayedEventIndex);

    if (displayedEventIndex > 0)
        backButton.setEnabled(true);
    else
        backButton.setEnabled(false);
    if (displayedEventIndex < quantEvents.size() - 1)
        forwardButton.setEnabled(true);
    else
        forwardButton.setEnabled(false);
    showEventSummaryButton.setEnabled(true);

    onePeakRatioRadioButton.setText("" + Rounder.round(quantEvent.getRatioOnePeak(), 2));
    Enumeration<AbstractButton> quantButtons = quantCurationButtonGroup.getElements();
    while (quantButtons.hasMoreElements())
        quantButtons.nextElement().setEnabled(true);
    Enumeration<AbstractButton> idButtons = idCurationButtonGroup.getElements();
    while (idButtons.hasMoreElements())
        idButtons.nextElement().setEnabled(true);

    navigationPanel.setBorder(BorderFactory
            .createTitledBorder("Event " + (displayedEventIndex + 1) + " / " + quantEvents.size()));

    ButtonModel buttonModelToSelect = null;
    switch (quantEvent.getQuantCurationStatus()) {
    case QuantEvent.CURATION_STATUS_UNKNOWN:
        buttonModelToSelect = unknownRadioButtonModel;
        break;
    case QuantEvent.CURATION_STATUS_GOOD:
        buttonModelToSelect = goodRadioButtonModel;
        break;
    case QuantEvent.CURATION_STATUS_BAD:
        buttonModelToSelect = badRadioButtonModel;
        break;
    case QuantEvent.CURATION_STATUS_RATIO_ONEPEAK:
        buttonModelToSelect = onePeakRadioButtonModel;
        break;
    }
    quantCurationButtonGroup.setSelected(buttonModelToSelect, true);

    switch (quantEvent.getIdCurationStatus()) {
    case QuantEvent.CURATION_STATUS_UNKNOWN:
        buttonModelToSelect = idUnknownRadioButtonModel;
        break;
    case QuantEvent.CURATION_STATUS_GOOD:
        buttonModelToSelect = idGoodRadioButtonModel;
        break;
    case QuantEvent.CURATION_STATUS_BAD:
        buttonModelToSelect = idBadRadioButtonModel;
        break;
    }
    idCurationButtonGroup.setSelected(buttonModelToSelect, true);

    multiChartDisplay.setPreferredSize(new Dimension(rightPanel.getWidth(), rightPanel.getHeight()));
    multiChartDisplay.updateUI();

    commentTextField.setText(quantEvent.getComment() != null ? quantEvent.getComment() : "");
    commentTextField.setToolTipText(
            quantEvent.getComment() != null ? quantEvent.getComment() : "Comment on this event");

    //dhmay danger of infinite loop here
    if (shouldUpdateTable)
        eventSummaryTable.getSelectionModel().setSelectionInterval(displayedEventIndex, displayedEventIndex);

    QuantEventAssessor.QuantEventAssessment assessment = quantEvent.getAlgorithmicAssessment();
    if (assessment == null) {
        assessmentTypeTextField.setText("");
        assessmentDescTextField.setText("");
        assessmentTypeTextField.setBackground(Color.LIGHT_GRAY);
    } else {
        assessmentTypeTextField.setText(QuantEventAssessor.flagReasonDescriptions[assessment.getStatus()]);
        assessmentDescTextField.setText(assessment.getExplanation());
        Color bgColor = assessmentPanel.getBackground();
        switch (assessment.getStatus()) {
        case QuantEventAssessor.FLAG_REASON_UNEVALUATED:
            bgColor = Color.YELLOW;
            break;
        case QuantEventAssessor.FLAG_REASON_OK:
            bgColor = Color.GREEN;
            break;
        default:
            bgColor = Color.RED;
            break;
        }
        assessmentTypeTextField.setBackground(bgColor);
    }
    assessmentDescTextField.setToolTipText(assessmentDescTextField.getText());

    showTheoreticalPeaks();
}

From source file:op.care.prescription.PnlPrescription.java

private java.util.List<Component> addCommands() {
    java.util.List<Component> list = new ArrayList<Component>();

    // checked for acls
    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {
        JideButton addRegular = GUITools.createHyperlinkButton("nursingrecords.prescription.btnNewRegular",
                SYSConst.icon22add, new ActionListener() {
                    @Override/*from   w  w w.ja v a 2 s  .  co m*/
                    public void actionPerformed(ActionEvent actionEvent) {
                        if (!resident.isActive()) {
                            OPDE.getDisplayManager()
                                    .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                            return;
                        }
                        new DlgRegular(new Prescription(resident), DlgRegular.MODE_NEW, new Closure() {
                            @Override
                            public void execute(Object o) {
                                if (o != null) {
                                    Pair<Prescription, java.util.List<PrescriptionSchedule>> returnPackage = (Pair<Prescription, List<PrescriptionSchedule>>) o;
                                    EntityManager em = OPDE.createEM();
                                    try {
                                        em.getTransaction().begin();
                                        em.lock(em.merge(resident), LockModeType.OPTIMISTIC);
                                        Prescription myPrescription = em.merge(returnPackage.getFirst());
                                        myPrescription
                                                .setRelation(UniqueTools.getNewUID(em, "__verkenn").getUid());
                                        BHPTools.generate(em, myPrescription.getPrescriptionSchedule(),
                                                new LocalDate(), true);
                                        em.getTransaction().commit();

                                        lstPrescriptions.add(myPrescription);
                                        Collections.sort(lstPrescriptions);
                                        final CollapsiblePane myCP = createCP4(myPrescription);
                                        buildPanel();
                                        SwingUtilities.invokeLater(new Runnable() {
                                            @Override
                                            public void run() {
                                                GUITools.scroll2show(jspPrescription,
                                                        myCP.getLocation().y - 100, new Closure() {
                                                            @Override
                                                            public void execute(Object o) {
                                                                GUITools.flashBackground(myCP, Color.YELLOW, 2);
                                                            }
                                                        });
                                            }
                                        });
                                    } catch (OptimisticLockException ole) {
                                        OPDE.warn(ole);
                                        if (em.getTransaction().isActive()) {
                                            em.getTransaction().rollback();
                                        }
                                        if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                            OPDE.getMainframe().emptyFrame();
                                            OPDE.getMainframe().afterLogin();
                                        }
                                        OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                                    } catch (Exception e) {
                                        if (em.getTransaction().isActive()) {
                                            em.getTransaction().rollback();
                                        }
                                        OPDE.fatal(e);
                                    } finally {
                                        em.close();
                                    }
                                    buildPanel();
                                }
                            }
                        });
                    }
                });
        list.add(addRegular);
    }

    // checked for acls
    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {
        JideButton addNewOnDemand = GUITools.createHyperlinkButton("nursingrecords.prescription.btnNewOnDemand",
                SYSConst.icon22add, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                        if (!resident.isActive()) {
                            OPDE.getDisplayManager()
                                    .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                            return;
                        }
                        new DlgOnDemand(new Prescription(resident), new Closure() {
                            @Override
                            public void execute(Object o) {
                                if (o != null) {

                                    EntityManager em = OPDE.createEM();
                                    try {
                                        em.getTransaction().begin();
                                        em.lock(em.merge(resident), LockModeType.OPTIMISTIC);
                                        Prescription myPrescription = em.merge((Prescription) o);
                                        myPrescription
                                                .setRelation(UniqueTools.getNewUID(em, "__verkenn").getUid());
                                        em.getTransaction().commit();

                                        lstPrescriptions.add(myPrescription);
                                        Collections.sort(lstPrescriptions);
                                        final CollapsiblePane myCP = createCP4(myPrescription);
                                        buildPanel();

                                        SwingUtilities.invokeLater(new Runnable() {
                                            @Override
                                            public void run() {
                                                GUITools.scroll2show(jspPrescription,
                                                        myCP.getLocation().y - 100, new Closure() {
                                                            @Override
                                                            public void execute(Object o) {
                                                                GUITools.flashBackground(myCP, Color.YELLOW, 2);
                                                            }
                                                        });
                                            }
                                        });

                                    } catch (OptimisticLockException ole) {
                                        OPDE.warn(ole);
                                        if (em.getTransaction().isActive()) {
                                            em.getTransaction().rollback();
                                        }
                                        if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                            OPDE.getMainframe().emptyFrame();
                                            OPDE.getMainframe().afterLogin();
                                        }
                                        OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                                    } catch (Exception e) {
                                        if (em.getTransaction().isActive()) {
                                            em.getTransaction().rollback();
                                        }
                                        OPDE.fatal(e);
                                    } finally {
                                        em.close();
                                    }
                                    buildPanel();
                                }
                            }
                        });
                    }
                });
        list.add(addNewOnDemand);
    }

    // checked for acls
    if (resident.isCalcMediUPR1() && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {
        JideButton buchenButton = GUITools.createHyperlinkButton("nursingrecords.prescription.newstocks",
                new ImageIcon(getClass().getResource("/artwork/22x22/shetaddrow.png")), new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                        if (!resident.isActive()) {
                            OPDE.getDisplayManager()
                                    .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                            return;
                        }
                        new DlgNewStocks(resident);
                        reload();
                    }
                });
        list.add(buchenButton);
    }

    // checked for acls
    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        JideButton printPrescription = GUITools.createHyperlinkButton("nursingrecords.prescription.print",
                SYSConst.icon22print2, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent actionEvent) {
                        SYSFilesTools.print(PrescriptionTools.getPrescriptionsAsHTML(lstPrescriptions, true,
                                true, false, tbClosed.isSelected(), true), true);
                    }
                });
        list.add(printPrescription);

        //            JideButton printDaily = GUITools.createHyperlinkButton("nursingrecords.prescription.printdailyplan", SYSConst.icon22print2, new ActionListener() {
        //                @Override
        //                public void actionPerformed(ActionEvent actionEvent) {
        //                    SYSFilesTools.print(PrescriptionTools.printDailyPlan(resident.getStation().getHome()), true);
        //                }
        //            });
        //            list.add(printDaily);
    }

    return list;
}

From source file:net.liuxuan.device.w3330.JIF_DrawChart_w3330.java

/**
 * ?jfreechart//from ww  w  .jav  a2 s .c  om
 */
public void initChart() {
    ts_wppm = new TimeSeries("PPM", Millisecond.class);
    ts_wppm_zero = new TimeSeries("PPM-Zero", Millisecond.class);
    ts_flux = new TimeSeries("Flux", Millisecond.class);
    ts_wvtr = new TimeSeries("WVTR", Millisecond.class);
    ts_tempcell = new TimeSeries(" Cell Temperature", Millisecond.class);
    ts_tempambi = new TimeSeries("Ambient Temperature", Millisecond.class);
    ts_status = new TimeSeries("Status", Millisecond.class);
    ts_fitting = new TimeSeries("fitting curve1", Millisecond.class);
    ts_fitting2 = new TimeSeries("fitting curve2", Millisecond.class);
    trcollection = new TimeSeriesCollection(ts_wppm);

    trcollection.addSeries(ts_wppm_zero);

    trcollection.addSeries(ts_wvtr);

    trcollection.addSeries(ts_fitting2);//ppm
    trcollection2 = new TimeSeriesCollection(ts_flux);

    trcollection2.addSeries(ts_fitting);//temp3

    trcollection2.addSeries(ts_tempcell);

    trcollection2.addSeries(ts_tempambi);

    trcollection2.addSeries(ts_status);
    //        timeseriescopylist.add(getTimeSeries(3).createCopy(0, getTimeSeries(3).getItemCount() - 1));
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("", "Time(s)", "PPM", trcollection,
            true, true, false);
    XYPlot xyplot = jfreechart.getXYPlot();

    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    Font fs = new Font("", Font.BOLD, 14);
    Font fs2 = new Font("", Font.BOLD, 12);

    XYLineAndShapeRenderer line0render = (XYLineAndShapeRenderer) xyplot.getRenderer(0);

    Color purple = new Color(139, 0, 255);

    line0render.setSeriesPaint(0, Color.blue);
    line0render.setSeriesPaint(1, Color.green);
    line0render.setSeriesPaint(2, Color.red);
    line0render.setSeriesPaint(3, purple);

    //        line0render.setSeriesPaint(3, Color.ORANGE);
    XYLineAndShapeRenderer line1render = new XYLineAndShapeRenderer();
    Color Rosered = new Color(230, 28, 100);
    line1render.setSeriesPaint(0, Color.orange);
    line1render.setSeriesPaint(1, Color.yellow);
    line1render.setSeriesPaint(2, Color.cyan);
    line1render.setSeriesPaint(3, Rosered);
    line1render.setBaseShapesVisible(false);
    xyplot.setRenderer(1, line1render);

    //??
    ValueAxis valueaxis = xyplot.getDomainAxis();

    //
    valueaxis.setLabelFont(fs);

    //
    valueaxis.setTickLabelFont(fs2);

    ValueAxis valueaxis2 = new NumberAxis("");
    valueaxis2.setLabelFont(fs);
    valueaxis2.setTickLabelFont(fs2);

    xyplot.setRangeAxis(1, valueaxis2);
    xyplot.setDataset(1, trcollection2);
    xyplot.mapDatasetToRangeAxis(1, 1);

    //??
    valueaxis.setAutoRange(true);
    //?? 7days
    //                valueaxis.setFixedAutoRange(604800000D);
    valueaxis = xyplot.getRangeAxis();

    valueaxis.setLabelFont(new Font("", Font.BOLD, 14));
    valueaxis.setLabelPaint(line0render.getSeriesPaint(0));
    valueaxis2.setLabelPaint(line1render.getSeriesPaint(0));

    jfreechart.getTitle().setFont(new Font("", Font.BOLD, 20));//
    jfreechart.getLegend().setItemFont(new Font("", Font.ITALIC, 15));
    xyplot.getRenderer(0).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}",
            new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000")));
    xyplot.getRenderer(1).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}",
            new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000")));
    chartPanel = new ChartPanel(jfreechart);

    initChartMenu();
    //        chartPanel.getPopupMenu().add(jmenuitem2);
    //        chartPanel.getPopupMenu().getPopupMenuListeners();

    chartPanel.setSize(950, 620);
    chartPanel.setPreferredSize(new Dimension(950, 620));
    jPanel_Show.add(chartPanel, BorderLayout.CENTER);
}

From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * The itemStateChanged method of the ItemListener interface.
 * @see ItemListener#itemStateChanged(ItemEvent)
 * //from ww  w .  java 2  s . c o  m
 * @param e The event which triggered this action.
 */
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        Object item = e.getSource();
        if (item == this.highContrastColorMenuItem) {
            graph.setBackground(Color.BLACK);
            graph.setForeground(Color.WHITE);
            graph.setPickedLabelColor(Color.WHITE);
            graph.setVertexPaint(Color.ORANGE.darker());
            graph.setPickedVertexPaint(Color.RED);
            graph.setPickedEdgePaint(Color.WHITE);
            heatMapPanel.setBackground(Color.BLACK);
            heatMapPanel.setForeground(Color.WHITE);
        } else if (item == this.normalColorMenuItem) {
            graph.setBackground(Color.WHITE);
            graph.setForeground(Color.BLACK);
            graph.setPickedLabelColor(Color.BLUE);
            graph.setVertexPaint(Color.ORANGE);
            graph.setPickedVertexPaint(Color.YELLOW);
            graph.setPickedEdgePaint(Color.BLACK);
            heatMapPanel.setForeground(Color.BLACK);
            heatMapPanel.setBackground(Color.WHITE);
        } else if (item == pearsonCalculationMenuItem) {
            correlationMethod.setValue(Correlation.PEARSON);
        } else if (item == spearmanCalculationMenuItem) {
            correlationMethod.setValue(Correlation.SPEARMAN);
        } else if (item == kendallCalculationMenuItem) {
            correlationMethod.setValue(Correlation.KENDALL);
        }
        graph.filterEdges();
        graph.repaint();
    }
}

From source file:com.josue.tileset.editor.Editor.java

private void addLightSourceTile(Tile tile) {
    if (!tile.equals(selectedTile) && selectedTile != null) {
        JLabel label = tileLabels.get(tile);
        if (tile.getId() == selectedTile.getId()) { //already contains
            selectedTile.setLight(null);
            label.setBorder(null);//from   ww  w .  j  a  v a2s . c o  m
        } else {
            selectedTile.setLight(new Light());
            selectedTile.getLight().setLightTileOffset(tile.getId() - selectedTile.getId());
            label.setBorder(new LineBorder(Color.YELLOW, 2));
            lightTb.setSelected(true);
        }
    }
}

From source file:op.FrmMain.java

private CollapsiblePane addNursingRecords(final Station station) {
    //        bwButtonMap = new HashMap<Resident, JideButton>();

    EntityManager em = OPDE.createEM();/*ww  w  . ja v a  2  s  . c  o m*/
    Query query;
    if (station == null) {
        query = em.createQuery("SELECT b FROM Resident b WHERE b.station IS NULL ORDER BY b.name, b.firstname");
    } else {
        query = em.createQuery(
                "SELECT b FROM Resident b WHERE b.station = :station ORDER BY b.name, b.firstname");
        query.setParameter("station", station);
    }
    ArrayList<Resident> residentList = new ArrayList<Resident>(query.getResultList());
    em.close();

    CollapsiblePane mypane = new CollapsiblePane(
            station == null ? SYSTools.xx("misc.msg.Archive") : station.getName());
    mypane.setFont(SYSConst.ARIAL14);
    mypane.setEmphasized(station != null && station.equals(StationTools.getStationForThisHost()));
    mypane.setStyle(CollapsiblePane.PLAIN_STYLE);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new VerticalLayout());
    labelPanel.setBackground(Color.WHITE);

    try {
        mypane.setCollapsed(!mypane.isEmphasized());
    } catch (PropertyVetoException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    if (!residentList.isEmpty() && station != null) {
        JideButton button = GUITools.createHyperlinkButton("opde.mainframe.printdailyplan",
                SYSConst.icon22print2, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                            PrescriptionTools.printDailyPlan(station, "html");
                        } else {
                            PrescriptionTools.printDailyPlan(station, "pdf");
                        }
                    }
                });
        button.setBackground(Color.WHITE);
        labelPanel.add(button);
    }

    for (final Resident resident : residentList) {
        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (currentResident != resident) {

                    if (previousProgButton != null) {
                        previousProgButton.setBackground(Color.WHITE);
                        previousProgButton.setOpaque(false);
                    }

                    previousProgButton = (JideButton) actionEvent.getSource();
                    previousProgButton.setBackground(Color.YELLOW);
                    previousProgButton.setOpaque(true);

                    currentResident = resident;

                    if (currentVisiblePanel instanceof PnlCare) {
                        ((NursingRecordsPanel) currentVisiblePanel).switchResident(resident);
                    } else {
                        setPanelTo(new PnlCare(resident, jspSearch));
                    }

                }
            }
        };

        JPanel singleButtonPanel = new JPanel();
        singleButtonPanel.setLayout(new BoxLayout(singleButtonPanel, BoxLayout.X_AXIS));
        singleButtonPanel.setBorder(null);

        singleButtonPanel.setOpaque(false);

        String titel = resident.getName() + ", " + resident.getFirstname() + " [" + resident.getRIDAnonymous()
                + "]";
        JideButton button = GUITools.createHyperlinkButton(titel, null, actionListener);
        button.setForegroundOfState(ThemePainter.STATE_DEFAULT,
                resident.getGender() == ResidentTools.FEMALE ? Color.red : Color.blue);
        button.setBackground(Color.WHITE);

        singleButtonPanel.add(button);

        OPDE.getDisplayManager().clearSubMessages();

        if (station != null) { // not for the archive
            JPanel pnl = new JPanel();
            pnl.setLayout(new BoxLayout(pnl, BoxLayout.X_AXIS));
            pnl.setOpaque(false);
            pnl.setBorder(null);

            setIconPanel(pnl, resident);

            synchronized (iconPanels) {
                iconPanels.put(resident, pnl);
            }

            singleButtonPanel.add(pnl);
        }

        labelPanel.add(singleButtonPanel);
    }

    mypane.setContentPane(labelPanel);
    listOfNursingrecords.add(mypane);
    return mypane;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JList buildJList(final Dimension dimension, final Object[] items, final JList list,
        final boolean sort) {
    if (items == null) {
        return null;
    }//from  www  .  j  a v  a2 s.  co  m
    list.setModel(new DefaultListModel() {

        @Override
        public void addElement(Object obj) {
            boolean inserted = false;
            if (sort) {
                for (int i = 0; i < this.getSize() && !inserted; i++) {
                    try {
                        final String comparator = ((obj == null) ? "" : obj.toString());
                        if (this.get(i).toString().compareTo(comparator) > 0) {
                            this.add(i, obj);
                            inserted = true;
                        }
                    } catch (Throwable t) {
                        log.error("Error al ordenar a " + obj + " y no lo incluimos", t);
                        inserted = true;
                    }
                }
            }
            if (!inserted) {
                super.addElement(obj);
            }
        }
    });
    log.trace("Lista con " + items.length + " objetos");
    for (Object obj : items) {
        ((DefaultListModel) list.getModel()).addElement(obj);
    }
    list.setCellRenderer(new DefaultListCellRenderer() {

        private static final long serialVersionUID = -987995602141400182L;

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel c = new JLabel();
            c.setText(value.toString());

            if (isSelected) {
                c.setOpaque(true);
                c.setBackground(Color.YELLOW);
            }
            return c;
        }
    });
    list.setMinimumSize(dimension);
    list.setFixedCellHeight(22);
    return list;
}