List of usage examples for java.awt Graphics getClipBounds
public abstract Rectangle getClipBounds();
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public void drawTable(Graphics gr, Point UL, Dataset dataset, int[] selection, Graphics navgGr, int countNavUnit) { Font f = getTableFont(squareL - 1); AnnotationManager annManager = AnnotationManager.getAnnotationManager(); String[] rowIds = dataset.getRowIds(); Set<String> annotations = dataset.getRowAnnotationNamesInUse(); if (annotations == null) { annotations = annManager.getManagedRowAnnotationNames(); }/*w w w .java2s . c o m*/ String[][] inf; // row annotation matrix String[] headers; // header of the row annotation matrix if (annotations.isEmpty()) { inf = new String[dataset.getDataLength()][1]; for (int i = 0; i < inf.length; i++) { inf[i][0] = rowIds[i]; } headers = new String[] { "Row ID" }; } else { headers = annotations.toArray(new String[annotations.size()]); inf = new String[dataset.getDataLength()][annotations.size()]; for (int i = 0; i < headers.length; i++) { //ann manager need to re implemeinted? AnnotationLibrary anns = annManager.getRowAnnotations(headers[i]); for (int j = 0; j < inf.length; j++) { inf[j][i] = rowIds[j];//anns.getAnnotation(rowIds[j]);// } } } Graphics2D g2d = (Graphics2D) gr; Graphics2D g2dNav = (Graphics2D) navgGr; g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2dNav.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); int X = UL.x; int Y = UL.y; // int H = squareL; int L = dataset.getDataLength(); int W = headers.length; JLabel l = new JLabel(" "); JLabel lNav = new JLabel(" "); // l.setFont(f); // l.setIconTextGap(2); javax.swing.border.Border UB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE); javax.swing.border.Border LB = javax.swing.BorderFactory.createMatteBorder(0, 0, 0, 0, Color.WHITE); // Color borderColor = hex2Rgb("#e3e3e3"); javax.swing.border.Border navBorder = javax.swing.BorderFactory.createMatteBorder(2, 0, 0, 0, Color.WHITE); l.setMaximumSize(new Dimension(200, squareL)); lNav.setSize(new Dimension(2, 5)); lNav.setBorder(navBorder); boolean drawTableHeader = false; //if there is not enough room for a header.. skip header. // if (UL.y < squareL) { // drawTableHeader = false; // } if (Wd == null) { Wd = new int[inf[0].length]; WdSUM = new int[inf[0].length]; if (drawTableHeader) { for (int i = 0; i < headers.length; i++) { l.setText(headers[i]); l.validate(); if (l.getPreferredSize().width > Wd[i]) { Wd[i] = l.getPreferredSize().width + 16; } } } for (String[] inf1 : inf) { for (int j = 0; j < Wd.length; j++) { if (squareL < 6) { Wd[j] = 5; continue; } l.setText(inf1[j]); l.validate(); if (l.getPreferredSize().width > Wd[j]) { Wd[j] = l.getPreferredSize().width + 16; } } } WdSUM[0] = 0; for (int i = 0; i < Wd.length; i++) { WdSUM[i] = -1; for (int j = 0; j < i; j++) { WdSUM[i] += Wd[j] + 3; } } } Rectangle BNDS = new Rectangle(); l.setBackground(Color.WHITE); l.setOpaque(true); lNav.setBackground(Color.WHITE); lNav.setOpaque(true); if (sideTree == null) { return; } f = getTableFont(squareL - 1); l.setFont(f); int[] LArr = sideTree.arrangement; int Rindex = 0; //draw the table header.. (if wanted) // if (drawTableHeader) { // // l.setBackground(Color.WHITE); // l.setForeground(Color.white); // // for (int j = 0; j < W; j++) { // X = UL.x + WdSUM[j]; // Y = UL.y; // BNDS.setBounds(X, Y, Wd[j], squareL + 1); // // if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { // continue; // } // gr.translate(X, Y); // l.setBounds(0, 0, Wd[j] + 1, squareL + 1); // l.setBorder(LB); // // if (squareL >= 6) { // l.setText(headers[j]); // } // l.validate(); // l.paint(gr); // gr.translate(-X, -Y); // } // } l.setForeground(Color.WHITE); boolean[] sel = selectedRows((selection == null ? null : selection), dataset); boolean coloredNav = false; int navCounter = 0; for (int i = 0; i < L; i++) { Rindex = LArr[i]; for (int j = 0; j < W; j++) { X = UL.x + WdSUM[j]; Y = UL.y + (squareL * (i + 1)); BNDS.setBounds(X, Y, Wd[j], squareL + 1); if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { continue; } if (sel[LArr[i]]) { for (Group group : dataset.getRowGroups()) { if (group.isActive()) { if (group.hasMember(Rindex)) { l.setBackground(group.getColor()); if (!coloredNav) { lNav.setBackground(Color.RED); lNav.setForeground(Color.RED); coloredNav = true; } break; } } } // l.setBackground(new Color(225, 225, 255)); } else { // // if (!coloredNav) { // lNav.setBackground(Color.WHITE); // lNav.setForeground(Color.WHITE); // } l.setBackground(Color.WHITE); } if (i != 0) gr.translate(X, Y); l.setBounds(0, 0, Wd[j] + 1, squareL + 1); if (i < L - 1) { l.setBorder(UB); } else { l.setBounds(0, 0, Wd[j] + 1, squareL + 1); l.setBorder(LB); } if (squareL >= 6) { l.setText(inf[Rindex][j]); } l.validate(); l.paint(gr); gr.translate(-X, -Y); } if (navCounter >= countNavUnit) { navCounter = 0; lNav.validate(); lNav.paint(navgGr); navgGr.translate(2, 0); coloredNav = false; lNav.setBackground(Color.WHITE); lNav.setForeground(Color.WHITE); } navCounter++; } // if (squareL < 6) { // return; // } // // l.setBackground(Color.WHITE); // f = getTableFont(squareL - 2); // //f = new Font("Arial",1,squareL-2); // l.setFont(f); // // // for (int j = 0; j < W; j++) { // X = UL.x + WdSUM[j]; // Y = UL.y; // // BNDS.setBounds(X, Y, Wd[j], squareL + 1); // if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(BNDS)) { // continue; // } // // gr.translate(X, Y); // l.setBounds(0, 0, Wd[j], squareL + 1); //// l.setBorder(javax.swing.BorderFactory.createLineBorder(GridCol)); // l.setText(headers[j]); // l.validate(); // gr.translate(-X, -Y); // } }
From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java
private void fillBackground(Graphics g) { final Rectangle clip = g.getClipBounds(); final Color col = g.getColor(); g.setColor(getBackground());// w w w. j av a 2s .c om g.fillRect(clip.x, clip.y, clip.width, clip.height); g.setColor(col); }
From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java
private static void paintComponents(Container c, Graphics g) { if (!c.isShowing()) return;/*w ww.j a va2 s.c o m*/ final int ncomponents = c.getComponentCount(); final Rectangle clip = g.getClipBounds(); int i = ncomponents - 1; while (i >= 0) { final Component component[] = c.getComponents(); final Component comp = component[i]; if (comp == null || !comp.isVisible()) continue; final Rectangle bounds = comp.getBounds(); Rectangle cr; if (clip == null) cr = new Rectangle(bounds); else cr = bounds.intersection(clip); if (cr.isEmpty()) continue; final Graphics cg = g.create(); cg.setClip(cr); cg.translate(bounds.x, bounds.y); try { comp.paint(cg); } catch (Throwable e) { // } cg.dispose(); i--; } }
From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphPanel.java
private static void drawHelp(final Graphics g) { final int x = (int) (g.getClipBounds().getWidth() / 2); final int y = (int) (g.getClipBounds().getHeight() / 2); final FontMetrics metrics = g.getFontMetrics(); final String name = "Right click here to add an operator"; final Rectangle2D rect = metrics.getStringBounds(name, g); final int stringWidth = (int) rect.getWidth(); g.setColor(Color.black);// www . j av a2s . c om g.drawString(name, x - stringWidth / 2, y); }
From source file:org.nuclos.client.ui.resplan.header.JHeaderGrid.java
@Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; super.paintComponent(g2d); g2d.setPaint(gridColor);/*from w w w . ja va 2 s.c om*/ Rectangle clipBounds = g.getClipBounds(); int[] indices = stripRangeForRect(clipBounds); int startIndex = indices[0]; int endIndex = indices[1]; Point p1, p2; p1 = new Point(); p2 = new Point(getWidth(), getHeight()); for (int i = startIndex; i <= endIndex; i++) { int gridLine = getGridLine(i); orientation.updateCoord(p1, gridLine); orientation.updateCoord(p2, gridLine); g2d.drawLine(p1.x, p1.y, p2.x, p2.y); } p1.setLocation(0, 0); p2.setLocation(getWidth(), getHeight()); int groupGridLine = 0; for (CategoryView v : groupings) { groupGridLine += v.size; orientation.opposite().updateCoord(p1, groupGridLine); orientation.opposite().updateCoord(p2, groupGridLine); g2d.drawLine(p1.x, p1.y, p2.x, p2.y); groupGridLine += GRID_SIZE; } for (int level = 0, levelCount = groupings.length; level < levelCount; level++) { for (HeaderCell cell : groupings[level].cells) { if (cell.endIndex < startIndex || cell.startIndex >= endIndex) continue; Rectangle rect = getRect(level, cell.startIndex, cell.endIndex); if (clipBounds != null && !clipBounds.intersects(rect)) continue; paintHeaderCell(g2d, rect, cell.levelValue); } } if (cellResizingRange != null) { Rectangle rect = new Rectangle(getWidth(), getHeight()); orientation.updateRange(rect, cellResizingRange); rect.grow(orientation.select(GRID_SIZE, 0), orientation.select(0, GRID_SIZE)); g2d.setColor(new Color(0x9999ff, false)); g2d.draw(rect); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f)); g2d.fill(rect); } }
From source file:org.photovault.swingui.PhotoCollectionThumbView.java
@Override public void paint(Graphics g) { super.paint(g); Graphics2D g2 = (Graphics2D) g; Rectangle clipRect = g.getClipBounds(); Dimension compSize = getSize(); // columnCount = (int)(compSize.getWidth()/columnWidth); int photoCount = 0; if (photos != null) { photoCount = photos.size();//from w w w . j a va 2s .co m } // Determine the grid size based on couln & row count columnsToPaint = columnCount; // if columnCount is not specified determine it based on row count if (columnCount < 0) { if (rowCount > 0) { columnsToPaint = photoCount / rowCount; if (columnsToPaint * rowCount < photoCount) { columnsToPaint++; } } else { columnsToPaint = (int) (compSize.getWidth() / columnWidth); } } int col = 0; int row = 0; Rectangle thumbRect = new Rectangle(); for (PhotoInfo photo : photos) { thumbRect.setBounds(col * columnWidth, row * rowHeight, columnWidth, rowHeight); if (thumbRect.intersects(clipRect)) { if (photo != null) { paintThumbnail(g2, photo, col * columnWidth, row * rowHeight, selection.contains(photo)); } } col++; if (col >= columnsToPaint) { row++; col = 0; } } // Paint the selection rectangle if needed if (dragSelectionRect != null) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke(new BasicStroke(1.0f)); g2.setColor(Color.BLACK); g2.draw(dragSelectionRect); g2.setColor(prevColor); g2.setStroke(prevStroke); lastDragSelectionRect = dragSelectionRect; } }
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
/** * paints this log item panel and all contained log items as specified. * //from w w w . ja v a 2s . c o m * @param g * the graphics object used for painting */ public void paintComponent(Graphics grx) { Graphics gr = grx.create(); if (this.isOpaque()) { gr.setColor(colorBg); gr.fillRect(0, 0, getWidth(), getHeight()); } if ((int) gr.getClipBounds().getMinX() < coUtil.getClipL() || (int) gr.getClipBounds().getMaxX() > coUtil.getClipR() || (int) gr.getClipBounds().getMinY() < coUtil.getClipU() || (int) gr.getClipBounds().getMaxY() > coUtil.getClipB()) { modelBuffer = null; } if (modelBuffer == null) { this.setToolTipText(null); if (this.getWidth() <= SCREENLENGTH) { coUtil.setClipL(0); coUtil.setClipR(this.getWidth()); } else { int x1 = (SCREENLENGTH - gr.getClipBounds().width) / 2; int x2 = (int) gr.getClipBounds().getMinX() - x1; if (x2 <= 0) { coUtil.setClipL(0); coUtil.setClipR(SCREENLENGTH); } else if (x2 + SCREENLENGTH >= this.getWidth()) { coUtil.setClipR(this.getWidth()); coUtil.setClipL(this.getWidth() - SCREENLENGTH); } else { coUtil.setClipL(x2); coUtil.setClipR(x2 + SCREENLENGTH); } } if (this.getHeight() <= SCREENLENGTH) { coUtil.setClipU(0); coUtil.setClipB(this.getHeight()); } else { int y1 = (SCREENLENGTH - gr.getClipBounds().height) / 2; int y2 = (int) gr.getClipBounds().getMinY() - y1; if (y2 <= 0) { coUtil.setClipU(0); coUtil.setClipB(SCREENLENGTH); } else if (y2 + SCREENLENGTH >= this.getHeight()) { coUtil.setClipU(this.getHeight() - SCREENLENGTH); coUtil.setClipB(this.getHeight()); } else { coUtil.setClipU(y2); coUtil.setClipB(y2 + SCREENLENGTH); } } coUtil.updateMilli2pixelsRatio(getWidth(), BORDER); if (dcop.isSizeCheckBoxSelected()) { drawModelBuffer(getWidth(), getHeight(), true); } else { drawModelBuffer_NO_SIZE(getWidth(), getHeight(), true); } } grx.drawImage(modelBuffer, coUtil.getClipL(), coUtil.getClipU(), this); // to do box for zoom if (p1 != null && p2 != null) { int x1 = Math.min(p1.x, p2.x); int y1 = Math.min(p1.y, p2.y); int width = Math.abs(p1.x - p2.x); int height = Math.abs(p1.y - p2.y); grx.drawRect(x1, y1, width, height); } }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
protected void paintComponentLane(Graphics g) { double percentileL = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceL()); double percentileU = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceU()); g.setFont(g.getFont().deriveFont((float) 10.0)); // set initial colors Color fgColor = null;/*from w w w . j a v a 2s . c om*/ Color bgColor = null; Color tmpColor = null; fgColor = null; bgColor = null; // calculate common coordinates int unitHeight = (this.getHeight() - 2 * border) / getHashMapSize(); int yTop = border; int yBottom = this.getHeight() - border; int pixStart = 0; String dateStr, timeStr, millisStr = null; // calculate area to be painted clipL = (int) g.getClipBounds().getMinX() - 1; clipR = (int) g.getClipBounds().getMaxX() + 1; // initialze start color fgColor = colorLogDark; bgColor = colorLogBright; // calculate current top int currentTop = yTop; // paint actual log lane (only the part in the clipping range // determined) Iterator itr = dcModel.getSortedKeySetList().iterator(); g.setFont(new Font("Dialog", Font.BOLD, 13)); int index = 0; currentTop = yTop; while (itr.hasNext()) { String dimName = (String) itr.next(); LogUnitList tempList = ((LogUnitList) dcModel.getItemMap().get(dimName)); long tempDuration; try { tempDuration = (tempList .getRightBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()) .getTime() - tempList.getLeftBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()).getTime()); } catch (Exception ce) { tempDuration = 0; } if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(dimName)) continue; g.setColor(bgColor); g.fillRect(pixStart, currentTop, clipR, currentTop + unitHeight); g.setColor(fgColor); // for bottleneck if (dcOptionPanel.getComponentType().equals(DottedChartPanel.ST_INST) && bBottleneckforInstances && tempDuration >= percentileL && tempDuration <= percentileU) g.setColor(Color.red); else g.setColor(Color.black); g.drawString(dimName, pixStart + 5, currentTop + 20); index++; currentTop = unit2Cord(index); // swap colors tmpColor = fgColor; fgColor = bgColor; bgColor = tmpColor; } g.setFont(new Font("Dialog", Font.PLAIN, 12)); // draw horizontal delimiters g.setColor(colorTimeLine); g.drawLine(clipL, yTop, clipR, yTop); g.drawLine(clipL, yBottom, clipR, yBottom); clipLeftTs = coord2timeMillis(clipL); clipRightTs = coord2timeMillis(clipR); // draw vertical lines // adjust width if (bAdjust) { adjustWidth(); bAdjust = false; } for (long timeStart = dcModel.getLogBoundaryLeft() .getTime(); timeStart < clipRightTs; timeStart += dcOptionPanel.getWidthDivider()) { pixStart = time2coord(timeStart) + border; cal.setTimeInMillis(timeStart); g.setColor(colorTimeLine); g.drawLine(pixStart, yTop, pixStart, yBottom); g.setColor(colorLogDark); g.setColor(Color.black); // to be deleted if (timeOption.equals(TIME_ACTUAL)) { dateStr = cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR); g.drawString(dateStr, pixStart + 2, yTop); timeStr = cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND); g.drawString(timeStr, pixStart + 2, yTop + 10); } else if (timeOption.equals(TIME_RELATIVE_TIME)) { long days = timeStart / 1000 / 60 / 60 / 24; long hours = (timeStart - days * 24 * 60 * 60 * 1000) / 1000 / 60 / 60; long minutes = (timeStart - days * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000) / 1000 / 60; long seconds = (timeStart - days * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000 - minutes * 60 * 1000) / 1000; timeStr = days + "days:" + hours + ":" + minutes + ":" + seconds; g.drawString(timeStr, pixStart + 2, yTop); } else if (timeOption.equals(TIME_RELATIVE_RATIO)) { timeStr = timeStart / 100 + "." + (timeStart - timeStart / 100 * 100) + "%"; g.drawString(timeStr, pixStart + 2, yTop); } else if (timeOption.equals(TIME_LOGICAL) || timeOption.equals(TIME_LOGICAL_RELATIVE)) { timeStr = String.valueOf(timeStart); g.drawString(timeStr, pixStart + 2, yTop); } } }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * paints this log item panel and all contained log items as specified. * /*from w ww . j av a2 s.c o m*/ * @param g * the graphics object used for painting */ public void paintComponent(Graphics grx) { selectedIDIndices.clear(); // for exporting bDrawLine = dca.getSettingPanel().isDrawLine(); // todo bBottleneck = dca.getSettingPanel().isBottleneck(); bBottleneckforInstances = dca.getSettingPanel().isBottleneckforInstance(); double percentileL = dcModel.getOverallStatistics().getPercentile(dca.getSettingPanel().getPercentileL()); double percentileU = dcModel.getOverallStatistics().getPercentile(dca.getSettingPanel().getPercentileU()); Graphics gr = grx.create(); if (this.isOpaque()) { gr.setColor(colorBg); gr.fillRect(0, 0, getWidth(), getHeight()); } // paint the time indicator equipped component lane paintComponentLane(gr); // calculate are to be painted int height = (int) ((double) (getHeight() - (2 * border))); int unitHeight = height / getHashMapSize(); int currentTop = 0; // paint items if (dcModel.getItemMap().size() > 0) { String key = null; AbstractLogUnit item = null; // iterate through sets int index = 0; for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) { key = (String) itSets.next(); // if key is not in instanceIDs, skip.. if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; currentTop = unit2Cord(index) + unitHeight / 2; LogUnitList tempUnitList = new LogUnitList(); AbstractLogUnit olditem = null; // for bottleneck boolean bInstances = false; boolean flag = true; if (dcOptionPanel.getComponentType().equals(DottedChartPanel.ST_INST) && bBottleneckforInstances) { LogUnitList tempUnitList2; tempUnitList2 = ((LogUnitList) dcModel.getItemMap().get(key)); double percentile2L = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceL()); double percentile2U = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceU()); long tempDuration = (tempUnitList2 .getRightBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()) .getTime() - tempUnitList2.getLeftBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()).getTime()); if (dcOptionPanel.getComponentType().equals(DottedChartPanel.ST_INST) && bBottleneckforInstances && tempDuration >= percentile2L && tempDuration <= percentile2U) bInstances = true; } // end for bottleneck //////// // iterate through items for (Iterator itItm = ((LogUnitList) dcModel.getItemMap().get(key)).iterator(); itItm.hasNext();) { item = (AbstractLogUnit) itItm.next(); if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType()) || !dcModel .getInstanceTypeToKeep().contains(item.getProcessInstance().getName()))) continue; if (bDrawLine && item.getType().equals(dca.getSettingPanel().getStartEvent())) tempUnitList.addEvent(item); assignColorByItem(item, gr); clipL = (int) gr.getClipBounds().getMinX() - 1; clipR = (int) gr.getClipBounds().getMaxX() + 1; long clipLeftTs2 = coord2timeMillis(clipL); long clipRightTs2 = coord2timeMillis(clipR); // if line is added if (bDrawLine && item.getType().equals(dca.getSettingPanel().getEndEvent())) { for (Iterator itr = tempUnitList.iterator(); itr.hasNext();) { AbstractLogUnit item2 = (AbstractLogUnit) itr.next(); if (item2.getElement().equals(item.getElement()) && item2.getProcessInstance().equals(item.getProcessInstance())) { paintItemLine(time2coord(item2.getCurrentTimeStamp()) + border, currentTop, time2coord(item.getCurrentTimeStamp()) + border, gr); tempUnitList.removeEvent(item2); break; } } } // if item is not shown on the screen, ship drawing if (item.getCurrentTimeStamp() == null || item.getCurrentTimeStamp().getTime() < clipLeftTs2 || item.getCurrentTimeStamp().getTime() > clipRightTs2) continue; // for botteleneck if (dcOptionPanel.getComponentType().equals(DottedChartPanel.ST_INST) && bBottleneck && olditem != null && (item.getCurrentTimeStamp().getTime() - olditem.getCurrentTimeStamp().getTime()) >= percentileL && (item.getCurrentTimeStamp().getTime() - olditem.getCurrentTimeStamp().getTime()) <= percentileU) { paintItemLineBottleneck(time2coord(olditem.getCurrentTimeStamp()) + border, currentTop, time2coord(item.getCurrentTimeStamp()) + border, gr); this.paintHighligtedItem(time2coord(olditem.getCurrentTimeStamp()) + border, currentTop, gr, assignShapeByItem(olditem)); this.paintHighligtedItem(time2coord(item.getCurrentTimeStamp()) + border, currentTop, gr, assignShapeByItem(item)); this.addExportingList(item); olditem = item; continue; } // paint an item if (bInstances) { this.paintHighligtedItem(time2coord(item.getCurrentTimeStamp()) + border, currentTop, gr, assignShapeByItem(item)); if (flag) { this.addExportingList(item); flag = false; } } else { this.paintItem(time2coord(item.getCurrentTimeStamp()) + border, currentTop, gr, assignShapeByItem(item)); } olditem = item; } // move y point index++; } } // to do box for zoom if (p1 != null && p2 != null) { int x1 = Math.min(p1.x, p2.x); int y1 = Math.min(p1.y, p2.y); int width = Math.abs(p1.x - p2.x); height = Math.abs(p1.y - p2.y); grx.drawRect(x1, y1, width, height); } // for exporting if (selectedIDIndices.size() > 0) { int tempArray[] = new int[selectedIDIndices.size()]; int i = 0; for (Iterator itr = selectedIDIndices.iterator(); itr.hasNext();) { tempArray[i++] = (int) ((Integer) itr.next()); } dca.setSelectedInstanceIndicesfromScreen(tempArray); } }
From source file:org.prom5.analysis.performance.dottedchart.ui.DottedChartPanel.java
protected void paintComponentLane(Graphics g) { double percentileL = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceL()); double percentileU = dcModel.getTimeStatistics().get(0) .getPercentile(dca.getSettingPanel().getPercentileforInstanceU()); g.setFont(g.getFont().deriveFont((float) 10.0)); // set initial colors Color fgColor = null;//from ww w .ja va 2s.co m Color bgColor = null; Color tmpColor = null; fgColor = null; bgColor = null; // calculate common coordinates int unitHeight = (this.getHeight() - 2 * border) / getHashMapSize(); int yTop = border; int yBottom = this.getHeight() - border; int pixStart = 0; String dateStr, timeStr, millisStr = null; // calculate area to be painted clipL = (int) g.getClipBounds().getMinX() - 1; clipR = (int) g.getClipBounds().getMaxX() + 1; // initialze start color fgColor = colorLogDark; bgColor = colorLogBright; // calculate current top int currentTop = yTop; // paint actual log lane (only the part in the clipping range determined) Iterator itr = dcModel.getSortedKeySetList().iterator(); g.setFont(new Font("Dialog", Font.BOLD, 13)); int index = 0; currentTop = yTop; while (itr.hasNext()) { String dimName = (String) itr.next(); LogUnitList tempList = ((LogUnitList) dcModel.getItemMap().get(dimName)); long tempDuration; try { tempDuration = (tempList .getRightBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()) .getTime() - tempList.getLeftBoundaryTimestamp(dcModel.getEventTypeToKeep(), dcModel.getInstanceTypeToKeep()).getTime()); } catch (Exception ce) { tempDuration = 0; } if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(dimName)) continue; g.setColor(bgColor); g.fillRect(pixStart, currentTop, clipR, currentTop + unitHeight); g.setColor(fgColor); // for bottleneck if (dcOptionPanel.getComponentType().equals(DottedChartPanel.ST_INST) && bBottleneckforInstances && tempDuration >= percentileL && tempDuration <= percentileU) g.setColor(Color.red); else g.setColor(Color.black); g.drawString(dimName, pixStart + 5, currentTop + 20); index++; currentTop = unit2Cord(index); // swap colors tmpColor = fgColor; fgColor = bgColor; bgColor = tmpColor; } g.setFont(new Font("Dialog", Font.PLAIN, 12)); // draw horizontal delimiters g.setColor(colorTimeLine); g.drawLine(clipL, yTop, clipR, yTop); g.drawLine(clipL, yBottom, clipR, yBottom); clipLeftTs = coord2timeMillis(clipL); clipRightTs = coord2timeMillis(clipR); // draw vertical lines // adjust width if (bAdjust) { adjustWidth(); bAdjust = false; } for (long timeStart = dcModel.getLogBoundaryLeft() .getTime(); timeStart < clipRightTs; timeStart += dcOptionPanel.getWidthDivider()) { pixStart = time2coord(timeStart) + border; cal.setTimeInMillis(timeStart); g.setColor(colorTimeLine); g.drawLine(pixStart, yTop, pixStart, yBottom); g.setColor(colorLogDark); g.setColor(Color.black); // to be deleted if (timeOption.equals(TIME_ACTUAL)) { dateStr = cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR); g.drawString(dateStr, pixStart + 2, yTop); timeStr = cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND); g.drawString(timeStr, pixStart + 2, yTop + 10); } else if (timeOption.equals(TIME_RELATIVE_TIME)) { long days = timeStart / 1000 / 60 / 60 / 24; long hours = (timeStart - days * 24 * 60 * 60 * 1000) / 1000 / 60 / 60; long minutes = (timeStart - days * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000) / 1000 / 60; long seconds = (timeStart - days * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000 - minutes * 60 * 1000) / 1000; timeStr = days + "days:" + hours + ":" + minutes + ":" + seconds; g.drawString(timeStr, pixStart + 2, yTop); } else if (timeOption.equals(TIME_RELATIVE_RATIO)) { timeStr = timeStart / 100 + "." + (timeStart - timeStart / 100 * 100) + "%"; g.drawString(timeStr, pixStart + 2, yTop); } else if (timeOption.equals(TIME_LOGICAL) || timeOption.equals(TIME_LOGICAL_RELATIVE)) { timeStr = String.valueOf(timeStart); g.drawString(timeStr, pixStart + 2, yTop); } } }