List of usage examples for java.awt Color YELLOW
Color YELLOW
To view the source code for java.awt Color YELLOW.
Click Source Link
From source file:com.juanhg.icewalker.IceWalkerApplet.java
public void paintEnergy() { if (model.remainEnergy()) { energySize = 33;/*w w w . j a va 2 s.c o m*/ } else { energySize = 0; } Color color; double energy = model.getEnergyValue(); if (energy > 0 && energy <= 200) { color = Color.red; } else if (energy > 200 && energy <= 400) { color = Color.orange; } else if (energy > 400 && energy <= 600) { color = Color.yellow; } else { color = Color.green; } chart.replacePlot(3, model.getEnergy(), "", color, energySize, true); }
From source file:UserInterface.DoctorAdmin.TakeRequestJPanel.java
private void cmbDoctorsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbDoctorsActionPerformed assignedDoctor = (Employee) cmbDoctors.getSelectedItem(); int count = 0; for (WorkRequest workRequest : assignedDoctor.getUserAccount().getWorkQueue().getWorkRequestList()) { if (!workRequest.getStatus().equals("Task completed")) { count++;//w ww . j a v a2 s.c o m } } if (count == 0) { lblStatus.setBackground(Color.green); lblStatus.setText("Available"); } else { lblStatus.setBackground(Color.yellow); lblStatus.setText("Assisting other patients"); } }
From source file:gui.EventReader.java
@Override public void run() { RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10 * 1000).build(); HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); //HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet( //"https://api.guildwars2.com/v1/events.json?world_id=" "http://gw2eventer.sourceforge.net/api/events.php?world_id=" + this.worldID); HttpResponse response;//from w ww . j a v a 2 s . com String line = ""; String out = ""; while (!isInterrupted()) { try { this.labelWorking.setText(this.workingString); try { response = client.execute(request); if (response.getStatusLine().toString().contains("200")) { BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8"))); line = ""; out = ""; while ((line = rd.readLine()) != null) { out = out + line; } } else { // http error request.releaseConnection(); this.refreshSelector.setEnabled(false); this.workingButton.setEnabled(false); this.jComboBoxLanguage.setEnabled(false); this.labelWorking.setText("connection error. retrying in... 10."); this.labelWorking.setVisible(true); Thread.sleep(10000); continue; } } catch (IOException | IllegalStateException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); request.releaseConnection(); this.refreshSelector.setEnabled(false); this.workingButton.setEnabled(false); this.jComboBoxLanguage.setEnabled(false); this.labelWorking.setText("connection error. retrying in... 10."); this.labelWorking.setVisible(true); Thread.sleep(10000); continue; //this.interrupt(); } request.releaseConnection(); JSONParser parser = new JSONParser(); Object obj; this.result.clear(); HashMap mehrfachEvents = new HashMap(); playSoundsList.clear(); this.overlayGui.clearActive(); String toolTip; try { obj = parser.parse(out); for (int i = 0; i < this.eventLabels.size(); i++) { JLabel iter = (JLabel) this.eventLabels.get(i); iter.setEnabled(false); iter.setForeground(Color.green); } for (Iterator iterator = ((JSONObject) obj).values().iterator(); iterator.hasNext();) { JSONArray arrayNew = (JSONArray) iterator.next(); for (int i = 0; i < arrayNew.size(); i++) { JSONObject obj2 = (JSONObject) arrayNew.get(i); if (obj2.get("event_id") != null) { String event = (String) obj2.get("event_id"); if (this.events.containsKey(event)) { //System.out.println("debug: " + event + "\n"); this.result.add(obj2.get("event_id")); int indexEvent = Integer.parseInt(((String[]) this.events.get(event))[0]); String eventPercent = ((String[]) this.events.get(event))[1]; String eventWav = ((String[]) this.events.get(event))[2]; String eventName = ((String[]) this.events.get(event))[3]; JLabel activeLabel = (JLabel) this.eventLabels.get(indexEvent - 1); JLabel activeLabelTimer = (JLabel) this.eventLabelsTimer.get(indexEvent - 1); int activeLabelInt = indexEvent - 1; String tmpEventName = eventPercent.substring(0, 1); Date dateNow = new Date(); long stampNow = dateNow.getTime(); if (this.timerStamps[activeLabelInt] != null) { long oldTimestamp = this.timerStamps[activeLabelInt].getTime(); long minsdiff = ((stampNow - oldTimestamp) / 1000 / 60); if (minsdiff >= 30) { activeLabelTimer.setEnabled(true); } else { activeLabelTimer.setEnabled(false); } if (minsdiff >= 60) { activeLabelTimer.setForeground(Color.red); } else { activeLabelTimer.setForeground(Color.green); } activeLabelTimer.setText(minsdiff + " mins (B)"); } /* if (activeLabel != null) { if (activeLabel.getToolTipText() != null) { if (activeLabel.getToolTipText().equals("")) { // null pointer?? activeLabel.setToolTipText((String) this.allEvents.get(obj2.get("event_id"))); } } }*/ if (obj2.get("state").equals("Active")) { activeLabel.setEnabled(true); //activeLabel.setToolTipText((String) this.allEvents.get(obj2.get("event_id"))); toolTip = activeLabel.getToolTipText(); if (toolTip != null) { if (toolTip.length() > 35) { toolTip = toolTip.substring(0, 35) + "..."; } } else { toolTip = ""; } if (tmpEventName.equals("B")) { this.markedBs[activeLabelInt] = true; activeLabelTimer.setVisible(false); this.timerStamps[activeLabelInt] = null; if (this.eventPlaySounds[activeLabelInt][2]) { if (!this.overlayGui.containsActiveB(eventName)) { this.overlayGui.addActiveB(eventName, "yellow", activeLabelInt); } } else { if (!this.overlayGui.containsActiveB(eventName)) { this.overlayGui.addActiveB(eventName, "green", activeLabelInt); } } } else { if (this.eventPlaySounds[activeLabelInt][2]) { if (!this.overlayGui.containsActivePre(eventName)) { this.overlayGui.addActivePreEvent(eventName, "yellow", activeLabelInt); } } else { if (!this.overlayGui.containsActivePre(eventName)) { this.overlayGui.addActivePreEvent(eventName, "green", activeLabelInt); } } } //activeLabel.setSize(100, activeLabel.getSize().height); //activeLabel.setText(eventPercent); URL url = this.getClass().getClassLoader() .getResource("media/sounds/" + eventWav + ".wav"); if (!playSoundsList.containsKey(url)) { if (!this.eventPlaySounds[activeLabelInt][2]) { if (tmpEventName.equals("B")) { if (this.eventPlaySounds[activeLabelInt][1]) { playSoundsList.put(url, activeLabel); } } else { if (this.eventPlaySounds[activeLabelInt][0]) { playSoundsList.put(url, activeLabel); } } } else { activeLabel.setForeground(Color.YELLOW); } } if (mehrfachEvents.containsKey(activeLabel)) { ((ArrayList) mehrfachEvents.get(activeLabel)).add(tmpEventName); } else { ArrayList tmpListe = new ArrayList(); tmpListe.add(tmpEventName); mehrfachEvents.put(activeLabel, tmpListe); } } else { if (tmpEventName.equals("B")) { if (this.markedBs[activeLabelInt]) { this.timerStamps[activeLabelInt] = dateNow; this.markedBs[activeLabelInt] = false; activeLabelTimer.setVisible(true); activeLabelTimer.setText("0 mins (B)"); } } } } } } } Iterator it = mehrfachEvents.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); JLabel label = (JLabel) pairs.getKey(); ArrayList liste = (ArrayList) pairs.getValue(); String outString = null; Collections.sort(liste, new Comparator<String>() { public int compare(String f1, String f2) { return -f1.toString().compareTo(f2.toString()); } }); for (int i = 0; i < liste.size(); i++) { if (outString == null) { outString = (String) liste.get(i); } else { outString += ", " + (String) liste.get(i); } } label.setText(outString); it.remove(); } this.labelServer.setOpaque(true); this.labelServer.setOpaque(false); this.labelServer.setEnabled(false); this.labelServer.setText(""); this.labelServer.setText(this.worldName); this.labelWorking.setVisible(false); this.refreshSelector.setEnabled(true); this.workingButton.setEnabled(true); this.jComboBoxLanguage.setEnabled(true); this.overlayGui.renderActive(); if (playSounds) { this.playThread = new Thread() { @Override public void run() { Iterator it = playSoundsList.entrySet().iterator(); while (it.hasNext() && !isInterrupted()) { AudioInputStream audioIn; Map.Entry pairs = (Map.Entry) it.next(); JLabel label = (JLabel) pairs.getValue(); try { playSoundsCurrent = (URL) pairs.getKey(); audioIn = AudioSystem.getAudioInputStream(playSoundsCurrent); Clip clip = null; String tmp = label.getText(); try { //label.setText(">" + tmp); //label.setText("<HTML><U>" + tmp + "<U><HTML>"); label.setForeground(Color.red); //Font font = label.getFont(); //Map attributes = font.getAttributes(); //attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); //label.setFont(font.deriveFont(attributes)); clip = AudioSystem.getClip(); clip.open(audioIn); clip.start(); } catch (LineUnavailableException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); } finally { try { audioIn.close(); } catch (IOException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); } } try { Thread.sleep(2000); //label.setText(tmp); label.setForeground(Color.green); } catch (InterruptedException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); this.interrupt(); //?? } } catch (UnsupportedAudioFileException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(EventReader.class.getName()).log(Level.SEVERE, null, ex); } it.remove(); } } }; this.playThread.start(); this.playThread.join(); } } catch (ParseException ex) { Logger.getLogger(ApiManager.class.getName()).log(Level.SEVERE, null, ex); this.refreshSelector.setEnabled(false); this.workingButton.setEnabled(false); this.jComboBoxLanguage.setEnabled(false); this.labelWorking.setText("connection error. retrying in... 10."); this.labelWorking.setVisible(true); Thread.sleep(10000); continue; } if (this.autoRefresh) { Thread.sleep(this.sleepTime * 1000); } else { this.interrupt(); } } catch (InterruptedException ex) { Logger.getLogger(ApiManager.class.getName()).log(Level.SEVERE, null, ex); this.interrupt(); } } }
From source file:com.ctsim.dmi.MainFrame.java
private void drawButtonYard(int x, int y, boolean isRequest) { FontMetrics metrics = g2.getFontMetrics(); int strWidth = metrics.stringWidth("Yard"); if (App.atpStatus == 1) { g2.setColor(Color.GREEN); g2.fillRect(x, y, bttnWidth, bttnHeight); g2.setColor(Color.BLACK); } else if (isRequest) { if (isFlashOn) { g2.setStroke(new BasicStroke(4)); g2.setColor(Color.YELLOW); } else {//from w w w. ja va2s. c o m g2.setStroke(new BasicStroke(2)); g2.setColor(Color.LIGHT_GRAY); } } else { g2.setStroke(new BasicStroke(2)); g2.setColor(Color.LIGHT_GRAY); } g2.drawRect(x, y, bttnWidth, bttnHeight); g2.drawString("Yard", x + (bttnWidth / 2) - strWidth / 2, y + bttnHeight - 5 - metrics.getHeight() / 2); }
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
/** * Creates a XY bar chart.//from w w w . j av a 2s .com * * @param title * @param categoryAxisLabel * @param valueAxisLabel * @param dataset * @param includeZero * @param shadow * @return */ public JFreeChart createXYBarChart(String title, String categoryAxisLabel, String valueAxisLabel, IntervalXYDataset dataset, boolean includeZero, boolean shadow) { JFreeChart chart = ChartFactory.createXYBarChart(title, categoryAxisLabel, false, valueAxisLabel, dataset, this.orientation, this.drawLegend, false, false); // set the background color for the chart... chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.025); domainAxis.setUpperMargin(0.025); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(includeZero); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(shadow); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesPaint(2, Color.green); renderer.setSeriesPaint(3, Color.darkGray); renderer.setSeriesPaint(4, Color.yellow); return chart; }
From source file:com.bdb.weather.display.freeplot.HistoricalFreePlot.java
/** * Create the series for wind values./*from w w w . j av a 2s .com*/ * * @param stroke The stroke that is used to draw the series * @param timeMethod The method that is used to "get" the date from the record */ private List<FreePlotSeries<HistoricalRecord>> createWindSeries(Stroke stroke, Function<HistoricalRecord, TemporalAccessor> timeMethod) { List<FreePlotSeries<HistoricalRecord>> list = new ArrayList<>(); int n = 0; list.add(new FreePlotSeries<>(SUSTAINED_WIND_SERIES_NAME, n++, Color.CYAN, stroke, HistoricalRecord::getAvgWindSpeed, timeMethod, INTERVAL_CLASS)); list.add(new FreePlotSeries<>(SUSTAINED_WIND_SERIES_NAME, n++, Color.ORANGE, stroke, HistoricalRecord::getHighWindSpeed, timeMethod, INTERVAL_CLASS)); list.add(new FreePlotSeries<>(WIND_GUST_SERIES_NAME, n++, Color.yellow, stroke, HistoricalRecord::getWindGustSpeed, timeMethod, INTERVAL_CLASS)); return list; }
From source file:hr.restart.util.chart.ChartXY.java
/** * Creates a BAR CHART// w w w . ja v a 2 s .co m * @param dataset The org.jfree.data.CategoryDataset * @param title The title * @return org.jfree.chart.JFreeChart */ private JFreeChart createBarChart(final CategoryDataset dataset, String title, PlotOrientation orientation) { final JFreeChart chart = ChartFactory.createBarChart(title, // chart title "", // domain axis label "", // range axis label dataset, // data orientation, // the plot orientation false, // include legend true, false); chart.setBackgroundPaint(Color.white); // the subtitle from the combobox if (jcb != null) chart.addSubtitle(new TextTitle(jcb.getSelectedItem().toString())); //subtitles setted by the user. if (getSubtitles() != null) for (int i = 0; i < getSubtitles().size(); i++) { chart.addSubtitle(new TextTitle(getSubtitles().get(i).toString())); } final Plot plot = chart.getPlot(); // get a reference to the plot for further customisation... final CategoryPlot categoryPlot = (CategoryPlot) plot; categoryPlot.setNoDataMessage("NO DATA!"); categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); categoryPlot.setRenderer(renderer); renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); // inside //renderer.setBaseItemLabelPaint(Color.white); Font font = new Font("SansSerif", Font.PLAIN, 7); Font derive = font.deriveFont(Font.BOLD); renderer.setBaseItemLabelFont(derive); // margin final CategoryAxis domainAxis = categoryPlot.getDomainAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); //domainAxis.setBottomCategoryLabelPosition(new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER)); domainAxis.setCategoryLabelPositions(new CategoryLabelPositions( new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER), // TOP new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER), // BOTTOM new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 0.30f), // LEFT new CategoryLabelPosition(RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT, CategoryLabelWidthType.RANGE, 0.30f) // RIGHT) )); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 0.0); renderer.setPositiveItemLabelPosition(p); if (comboBoxOrientation != null) { if (comboBoxOrientation.getSelectedItem() == "Vertikalni") { domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); } } return chart; }
From source file:base.BasePlayer.ClusterTable.java
void drawScreen(Graphics g) { try {/* www.j a v a 2 s. co m*/ buf.setColor(Color.black); buf.fillRect(0, 0, this.getWidth(), tablescroll.getViewport().getHeight()); genemutcount = 0; hoverVar = null; hoverSample = -1; headerHover = -1; geneHeaderHover = -1; if (!mouseDrag) { resizeColumn = -1; } if (Main.drawCanvas.clusterNodes != null) { firstrow = tablescroll.getVerticalScrollBar().getValue() / rowHeight - 1 - Main.drawCanvas.clusterNodes.size(); if (firstrow < 0) { firstrow = 0; } for (int i = 0; i < Main.drawCanvas.clusterNodes.size(); i++) { dot = false; if ((i + 1 + samplecount + Main.drawCanvas.clusterNodes.size()) * rowHeight < tablescroll .getVerticalScrollBar().getValue()) { continue; } if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue() + tablescroll.getViewport().getHeight()) { break; } if (mouseY >= (rowHeight * (i + genemutcount + 1)) && mouseY < (rowHeight * (i + genemutcount + 2))) { hoverNode = Main.drawCanvas.clusterNodes.get(i); } try { buf.setColor(Color.darkGray); buf.drawLine(4, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); buf.setColor(linecolor); cluster = Main.drawCanvas.clusterNodes.get(i); if (cluster.varnodes.get(0).getTranscripts() != null) { if (!chrom.equals(cluster.varnodes.get(0).getTranscripts().get(0).getChrom())) { chrom = cluster.varnodes.get(0).getTranscripts().get(0).getChrom(); } } else { if (!chrom.equals(cluster.varnodes.get(0).getExons().get(0).transcript.getChrom())) { chrom = cluster.varnodes.get(0).getExons().get(0).transcript.getChrom(); } } for (int c = 0; c < header.size(); c++) { if (Main.drawCanvas.clusterNodes.get(i).equals(hoverNode) || Main.drawCanvas.clusterNodes.get(i).equals(selectedNode)) { buf.setColor(Color.yellow); } else { buf.setColor(Color.white); } if (c == 0) { buf.drawString("" + cluster.ID, (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (c == 1) { buf.drawString("" + cluster.nodecount, (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (c == 2) { buf.drawString("" + cluster.width, (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (c == 3) { buf.drawString( chrom + ":" + MethodLibrary.formatNumber(cluster.varnodes.get(0).getPosition()), (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (c == 4) { buf.drawString( "" + MethodLibrary.round((cluster.nodecount / (double) cluster.width), 4), (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else if (c == 5) { if (cluster.varnodes.get(0).getExons() != null) { if (cluster.varnodes.get(0).coding) { buf.setColor(Color.red); buf.drawString( cluster.varnodes.get(0).getExons().get(0).getTranscript() .getGenename() + " (Coding)", (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.lightGray); buf.drawString( cluster.varnodes.get(0).getExons().get(0).getTranscript() .getGenename() + " (UTR)", (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } else if (cluster.varnodes.get(0).isInGene()) { buf.setColor(Color.lightGray); buf.drawString( cluster.varnodes.get(0).getTranscripts().get(0).getGenename() + " (Intronic)", (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.gray); if (!cluster.varnodes.get(0).getTranscripts().get(0) .equals(cluster.varnodes.get(0).getTranscripts().get(1))) { buf.drawString( cluster.varnodes.get(0).getTranscripts().get(0).getGenename() + " ... " + cluster.varnodes .get(0).getTranscripts().get(1).getGenename(), (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { if (cluster.varnodes.get(0).getTranscripts().get(0) .getEnd() > cluster.varnodes.get(0).getPosition()) { buf.drawString( " ... " + cluster.varnodes .get(0).getTranscripts().get(0).getGenename(), (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString( cluster.varnodes.get(0).getTranscripts().get(0).getGenename() + " ... ", (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } else if (c == 6) { if (cluster.varnodes.get(0).getBedHits() != null) { bedarray = MethodLibrary.makeTrackArray(cluster.varnodes.get(0), null); for (int b = 0; b < bedarray.length; b++) { buf.setColor(Color.black); if (b == bedarray.length - 1) { buf.fillRect((int) header.get(c + b)[1] + 1, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth() - (int) header.get(c + b)[1], rowHeight - 1); } else { buf.fillRect((int) header.get(c + b)[1] + 1, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) header.get(c + b)[2], rowHeight - 1); } buf.setColor(Color.white); if (bedarray[b] != null) { buf.drawString(bedarray[b].toString(), (int) header.get(c + b)[1] + 5, (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } if (c < header.size() - 1 - Main.bedCanvas.bedTrack.size()) { buf.setColor(Color.black); buf.fillRect((int) header.get(c + 1)[1] + 1, (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) header.get(c + 1)[2], rowHeight - 1); } } buf.setColor(Color.darkGray); buf.drawLine(3, rowHeight + 3, 3, (rowHeight * (i + genemutcount + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3); for (int r = 0; r < header.size(); r++) { buf.drawLine((int) header.get(r)[1], (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) header.get(r)[1], (rowHeight * (i + genemutcount + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3); } if (selectedNode != null && selectedNode.equals(cluster)) { hoverSample = -1; genemutcount = aminoarray.size() + 1; listAdd = 1; buf.drawLine(20, (rowHeight * (i + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3); drawGeneheader((rowHeight * (i + listAdd + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); for (int s = 0; s < aminoarray.size(); s++) { buf.setColor(Color.darkGray); buf.drawLine(21, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); if (mouseY >= (rowHeight * (i + s + listAdd + 2)) && mouseY < (rowHeight * (i + s + listAdd + 3))) { hoverNode = null; hoverVar = aminoarray.get(s).getNode(); hoverString = aminoarray.get(s).getRow(); buf.setColor(Color.white); for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getSample().getIndex(); break; } } } else { if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("nonsense")) { buf.setColor(Color.red); } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("missense")) { buf.setColor(Color.yellow); } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("synonymous")) { buf.setColor(Color.green); } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("UTR")) { buf.setColor(Color.lightGray); } else { buf.setColor(Color.gray); } } if (!aminoarray.get(s).getRow()[1].equals("1")) { buf.drawString("Multiple", 24, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { buf.drawString( aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .getSample().getName(), 24, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); break; } } } if (hoverVar != null && hoverString.equals(aminoarray.get(s).getRow())) { //TODO textcolor = Color.white; } else { if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("nonsense")) { textcolor = Color.red; } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("missense")) { textcolor = Color.yellow; } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]) .equals("synonymous")) { textcolor = Color.green; } else if (aminoarray.get(s).getRow()[3].contains("UTR")) { textcolor = Color.lightGray; } else { textcolor = Color.gray; } } for (int h = 1; h < 4; h++) { buf.setColor(Color.black); buf.fillRect((int) geneheader.get(h)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(h)[2], rowHeight - 1); buf.setColor(textcolor); buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(h)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } if (aminoarray.get(s).getRow()[1].equals("1")) { buf.setColor(Color.black); buf.fillRect((int) geneheader.get(4)[1] + 10, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .isHomozygous()) { buf.drawString( "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(0).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(0).getCoverage() + ")", (int) geneheader.get(4)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (Control.controlData.controlsOn) { cases = 2; casefreq = 2 / (double) (Main.varsamples * 2); } } else { buf.drawString( "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(0).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(0).getCoverage() + ")", (int) geneheader.get(4)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (Control.controlData.controlsOn) { cases = 1; casefreq = 1 / (double) (Main.varsamples * 2); } } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(5)[1] + 1, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + aminoarray.get(s).getNode().vars .get(v).getValue().get(0).getQuality(), (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } if (Control.controlData.controlsOn) { cases = 0; for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0) .isHomozygous()) { cases += Integer.parseInt(aminoarray.get(s).getRow()[1]) * 2; } else { cases += Integer.parseInt(aminoarray.get(s).getRow()[1]); } } } casefreq = cases / (double) (Main.varsamples * 2); } buf.setColor(textcolor); buf.drawString(aminoarray.get(s).getRow()[4], (int) geneheader.get(6)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); if (Control.controlData.controlsOn) { buf.setColor(textcolor); for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(aminoarray.get(s).getRow()[5])) { vararray = aminoarray.get(s).getNode().vars.get(v).getValue(); controlarray = new SampleNode[Control.controlData.fileArray.size()]; if (vararray.get(vararray.size() - 1).alleles != null) { for (int e = vararray.size() - 1; e > 0; e--) { if (vararray.get(e).alleles == null) { break; } controlarray[vararray.get(e).getControlSample() .getIndex()] = vararray.get(e); } } for (int e = 0; e < controlarray.length; e++) { if (Control.controlData.fileArray.get(e).controlOn) { if (controlarray[e] == null) { buf.setColor(Color.black); buf.fillRect( (int) geneheader .get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString("0", (int) geneheader .get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString("-", (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + rowHeight); } else { buf.setColor(Color.black); buf.fillRect( (int) geneheader .get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + MethodLibrary.round(controlarray[e].alleles / (double) controlarray[e].allelenumber, 2), (int) geneheader .get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString("" + MethodLibrary .round(casefreq / (controlarray[e].alleles / (double) controlarray[e].allelenumber), 2) + " (p=" + MethodLibrary.round( VariantHandler.table.fe.getRightTailedP( cases, Main.varsamples * 2 - cases, controlarray[e].alleles, controlarray[e].allelenumber - controlarray[e].alleles), 2) + ")", (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll .getVerticalScrollBar().getValue() + rowHeight); } } else { buf.setColor(Color.black); buf.fillRect( (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(Color.darkGray); buf.drawString("Apply controls", (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.black); buf.fillRect( (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(Color.darkGray); buf.drawString("-", (int) geneheader .get(this.geneheaderlength + e * 2 + 1)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } } else { buf.setColor(Color.darkGray); for (int e = geneheaderlength; e < geneheader.size(); e++) { if (geneheader.get(e)[0] instanceof ControlFile) { buf.drawString("Apply controls", (int) geneheader.get(e)[1] + 14, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } buf.setColor(Color.lightGray); } vararray = null; if (Main.bedCanvas.bedOn) { for (int a = 0; a < aminoarray.size(); a++) { bedarray = MethodLibrary.makeTrackArray(aminoarray.get(a).getNode(), aminoarray.get(a).getRow()[5]); if (bedarray != null) { for (int b = 0; b < bedarray.length; b++) { buf.setColor(Color.black); if (b == bedarray.length - 1) { buf.fillRect( (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 12, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth() - (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1], rowHeight - 1); } else { buf.fillRect( (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 12, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[2], rowHeight - 1); } buf.setColor(Color.white); if (bedarray[b] != null) { buf.drawString(bedarray[b].toString(), (int) geneheader.get(geneheaderlength + Control.controlData.fileArray.size() * 2 + b)[1] + 14, (rowHeight * (i + a + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } } } } } buf.setColor(Color.darkGray); for (int j = 0; j < geneheader.size(); j++) { buf.drawLine((int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue() + 4, (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); } if (selectedVar != null && selectedString.equals(aminoarray.get(s).getRow()) && Integer.parseInt(selectedString[1]) > 1) { //hoverSample = -1; pointer = 0; //TODO for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) { if (aminoarray.get(s).getNode().vars.get(v).getKey() .equals(selectedString[5])) { for (int l = 0; l < aminoarray.get(s).getNode().vars.get(v).getValue() .size(); l++) { if (aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).alleles != null) { break; } if (mouseY > (rowHeight * (i + s + pointer + 4)) && mouseY < (rowHeight * (i + s + pointer + 5))) { textcolor = Color.white; hoverVar = aminoarray.get(s).getNode(); hoverString = aminoarray.get(s).getRow(); hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getSample().getIndex(); } else { textcolor = Color.lightGray; } // if(aminoarray.get(s).getNode().getSamples().get(l).getVariation().equals(selectedString[5])) { buf.setColor(textcolor); buf.drawString( aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .getSample().getName(), 30, (rowHeight * (i + s + pointer + 4)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); pointer++; // } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(4)[1] + 10, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l) .isHomozygous()) { buf.drawString( "Hom (" + aminoarray.get(s).getNode().vars.get(v) .getValue().get(l).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v) .getValue().get(l).getCoverage() + ")", (int) geneheader.get(4)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } else { buf.drawString( "Het (" + aminoarray.get(s).getNode().vars.get(v) .getValue().get(l).getCalls() + "/" + aminoarray.get(s).getNode().vars.get(v) .getValue().get(l).getCoverage() + ")", (int) geneheader.get(4)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); } buf.setColor(Color.black); buf.fillRect((int) geneheader.get(5)[1] + 10, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + 4, this.getWidth(), rowHeight - 1); buf.setColor(textcolor); buf.drawString( "" + aminoarray.get(s).getNode().vars.get(v).getValue() .get(l).getQuality(), (int) geneheader.get(5)[1] + 14, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight); buf.setColor(Color.darkGray); for (int j = 4; j < 7; j++) { buf.drawLine((int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue(), (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + pointer + 3)) - tablescroll.getVerticalScrollBar().getValue() + rowHeight + 2); } } } } listAdd = Integer.parseInt(selectedString[1]) + 1; genemutcount = aminoarray.size() + listAdd; buf.setColor(Color.darkGray); buf.drawLine(21, (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue() + 3); } } } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); } } buf.setColor(Color.darkGray); buf.drawLine(4, (rowHeight * (Main.drawCanvas.clusterNodes.size() + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3, this.getWidth(), (rowHeight * (Main.drawCanvas.clusterNodes.size() + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3); } drawHeader(); if (headerHover == -1 && geneHeaderHover == -1) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } else { if (resizeColumn == -1) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); } } g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.fenyo.gnetwatch.GUI.BasicComponent.java
/** * Paints axis./*ww w. j a va 2s. c o m*/ * @param none. * @return long current time displayed at the axis bottom. */ // AWT thread private long paintAxis() { backing_g.setColor(new Color(50, 50, 50)); backing_g.fillRect(axis_margin_left, axis_margin_top, dimension.width - axis_margin_left - axis_margin_right + 1, dimension.height - axis_margin_top - axis_margin_bottom + 1); backing_g.setColor(Color.YELLOW); backing_g.drawLine(axis_margin_left, dimension.height - axis_margin_bottom, dimension.width - axis_margin_right, dimension.height - axis_margin_bottom); backing_g.drawLine(axis_margin_left, axis_margin_top, axis_margin_left, dimension.height - axis_margin_bottom); backing_g.setColor(Color.YELLOW.darker()); backing_g.drawLine(axis_margin_left + 1, axis_margin_top, dimension.width - axis_margin_right, axis_margin_top); backing_g.drawLine(dimension.width - axis_margin_right, axis_margin_top, dimension.width - axis_margin_right, dimension.height - axis_margin_bottom - 1); int vinterval_pos = dimension.height - axis_margin_bottom - pixels_per_vinterval; backing_g.setColor(Color.YELLOW.darker().darker().darker()); while (vinterval_pos + 9 * (pixels_per_vinterval / 10) > axis_margin_top) { int cpt = 10; while (--cpt > 0) if (vinterval_pos + cpt * (pixels_per_vinterval / 10) > axis_margin_top) backing_g.drawLine(axis_margin_left + 1, vinterval_pos + cpt * (pixels_per_vinterval / 10), dimension.width - axis_margin_right - 1, vinterval_pos + cpt * (pixels_per_vinterval / 10)); vinterval_pos -= pixels_per_vinterval; } final long now; if (manual_mode) now = manual_now; else now = System.currentTimeMillis(); final long time_to_display = now - now % _getDelayPerInterval(); final int pixels_offset = (pixels_per_interval * (int) (now % _getDelayPerInterval())) / (int) _getDelayPerInterval(); final int last_interval_pos = dimension.width - axis_margin_right - pixels_offset; backing_g.setClip(axis_margin_left, 0, dimension.width - axis_margin_left - axis_margin_right, dimension.height); int current_interval_pos = last_interval_pos + pixels_per_interval; long current_time_to_display = time_to_display + _getDelayPerInterval(); boolean stop = false; while (stop == false) { backing_g.setColor(Color.YELLOW.darker()); backing_g.drawLine(current_interval_pos, axis_margin_top, current_interval_pos, dimension.height - axis_margin_bottom + std_separator); int cpt = 10; backing_g.setColor(Color.YELLOW.darker().darker().darker()); while (--cpt > 0) if (current_interval_pos - cpt * (pixels_per_interval / 10) > axis_margin_left) backing_g.drawLine(current_interval_pos - cpt * (pixels_per_interval / 10), axis_margin_top + 1, current_interval_pos - cpt * (pixels_per_interval / 10), dimension.height - axis_margin_bottom - 1); final String current_time_str = formatTime(current_time_to_display); final String current_date_str = formatDate(current_time_to_display); final TextLayout current_layout = new TextLayout(current_time_str, backing_g.getFont(), backing_g.getFontRenderContext()); final TextLayout current_layout_date = new TextLayout(current_date_str, backing_g.getFont(), backing_g.getFontRenderContext()); final Rectangle2D current_bounds = current_layout.getBounds(); final Rectangle2D current_bounds_date = current_layout_date.getBounds(); backing_g.setColor(Color.YELLOW.darker()); backing_g.drawString(current_time_str, current_interval_pos - (int) (current_bounds.getWidth() / 2), dimension.height - axis_margin_bottom + (int) current_bounds.getHeight() + 2 * std_separator); backing_g.setColor(Color.YELLOW.darker().darker()); backing_g.drawString(current_date_str, current_interval_pos - (int) (current_bounds_date.getWidth() / 2), 3 + ((int) current_bounds.getHeight()) + dimension.height - axis_margin_bottom + (int) current_bounds.getHeight() + 2 * std_separator); if (current_interval_pos - current_bounds.getWidth() / 2 < axis_margin_left) stop = true; current_interval_pos -= pixels_per_interval; current_time_to_display -= _getDelayPerInterval(); } backing_g.setClip(null); vinterval_pos = dimension.height - axis_margin_bottom - pixels_per_vinterval; int value = value_per_vinterval; while (vinterval_pos > axis_margin_top) { backing_g.setColor(Color.YELLOW.darker()); backing_g.drawLine(axis_margin_left - std_separator, vinterval_pos, dimension.width - axis_margin_right, vinterval_pos); final String value_str; if (value >= 1000000) value_str = "" + value / 1000000 + "M"; else if (value >= 1000) value_str = "" + value / 1000 + "k"; else value_str = "" + value; final TextLayout current_layout = new TextLayout(value_str, backing_g.getFont(), backing_g.getFontRenderContext()); final Rectangle2D current_bounds = current_layout.getBounds(); backing_g.setColor(Color.YELLOW.darker()); backing_g.drawString(value_str, axis_margin_left - (int) current_bounds.getWidth() - 2 * std_separator, vinterval_pos + (int) (current_bounds.getHeight() / 2)); vinterval_pos -= pixels_per_vinterval; value += value_per_vinterval; } return now; }
From source file:op.care.reports.PnlReport.java
private java.util.List<Component> addCommands() { java.util.List<Component> list = new ArrayList<Component>(); /***//ww w. jav a 2 s. c o m * _ _ * | \ | | _____ __ * | \| |/ _ \ \ /\ / / * | |\ | __/\ V V / * |_| \_|\___| \_/\_/ * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { JideButton addButton = GUITools.createHyperlinkButton(SYSTools.xx("misc.commands.new"), new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")), new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!resident.isActive()) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident")); return; } new DlgReport(new NReport(resident), new Closure() { @Override public void execute(Object report) { if (report != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport myReport = (NReport) em.merge(report); em.getTransaction().commit(); final String keyYear = Integer .toString(new DateTime(myReport.getPit()).getYear()) + ".year"; if (!cpMap.containsKey(keyYear)) { reloadDisplay(); } else { final String keyDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyDay); } synchronized (valuecache) { if (valuecache.containsKey(keyDay)) { valuecache.get(keyDay).add(myReport); Collections.sort(valuecache.get(keyDay)); } } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } if (minmax.isAfter(new DateTime(myReport.getPit()))) { minmax.setStart(new DateTime(myReport.getPit())); } if (minmax.isBefore(new DateTime(myReport.getPit()))) { minmax.setEnd(new DateTime(myReport.getPit())); } createCP4Day(new LocalDate(myReport.getPit())); expandDay(new LocalDate(myReport.getPit())); buildPanel(); GUITools.scroll2show(jspReports, cpMap.get(keyDay), cpsReports, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(myReport), 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(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); list.add(addButton); } return list; }