public void setInput( String date, long startTime, long endTime, int objHash, String objName, String objType, String counter, int serverId) throws Exception { this.date = date; this.objHash = objHash; this.objName = objName; this.objType = objType; this.counter = counter; this.serverId = serverId; this.startTime = startTime; this.endTime = endTime; String date2 = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8); Server server = ServerManager.getInstance().getServer(serverId); String svrName = ""; String counterDisplay = ""; String counterUnit = ""; if (server != null) { svrName = server.getName(); counterDisplay = server.getCounterEngine().getCounterDisplayName(objType, counter); counterUnit = server.getCounterEngine().getCounterUnit(objType, counter); } desc = "ⓢ" + svrName + " | (Pasttime) [" + objName + "][" + date2 + "] " + counterDisplay + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : ""); setViewTab(objType, counter, serverId); if (this.trace != null) { this.trace.setName(objName); this.trace.setTraceColor(AgentColorManager.getInstance().assignColor(objType, objHash)); ChartUtil.addSolidLine( xyGraph, provider, AgentColorManager.getInstance().assignColor(objType, objHash)); } ExUtil.asyncRun( new Runnable() { public void run() { load(); } }); }
private void createDataProvider() { traceDataProvider = new CircularBufferDataProvider(true); traceDataProvider.setBufferSize(288); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); // create the trace trace = new Trace("TOTAL", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); trace.getXAxis().setFormatPattern("HH:mm:ss"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); trace.setTraceType(TraceType.AREA); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); // add the trace to xyGraph xyGraph.addTrace(trace); ChartUtil.addSolidLine(xyGraph, traceDataProvider, ColorUtil.getInstance().TOTAL_CHART_COLOR); }
public void createPartControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(ChartUtil.gridlayout(1)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); table = build(comp); table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); table.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F5) { reload(); } } }); stacktrace = new StyledText(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); stacktrace.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); stacktrace.setText(""); stacktrace.setFont(new Font(null, "verdana", 10, 0)); stacktrace.setMargins(10, 10, 10, 10); listener = new CustomLineStyleListener(false, defaultHighlightings, false); stacktrace.addLineStyleListener(listener); IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); man.add( new Action("reload", ImageUtil.getImageDescriptor(Images.refresh)) { public void run() { reload(); } }); comp.addControlListener(new TableControlAdapter(table, cols, new int[] {3, -1})); }
public void createPartControl(Composite parent) { window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Composite composite = new Composite(parent, SWT.NONE); GridLayout gLayout = new GridLayout(1, true); gLayout.horizontalSpacing = 0; gLayout.marginHeight = 0; gLayout.marginWidth = 0; composite.setLayout(gLayout); createUpperMenu(composite); Composite chartComposite = new Composite(composite, SWT.NONE); chartComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); chartComposite.setLayout(UIUtil.formLayout(0, 0)); this.marginTargetComposite = chartComposite; chartComposite.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); canvas = new FigureCanvas(chartComposite); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); canvas.setLayoutData(UIUtil.formData(0, leftMargin, 0, 0, 100, 0, 100, 0)); canvas.addControlListener( new ControlListener() { boolean lock = false; public void controlResized(ControlEvent e) { org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea(); if (!lock) { lock = true; if (ChartUtil.isShowDescriptionAllowSize(r.height)) { CounterPastLongDateTotalView.this.setContentDescription(desc); } else { CounterPastLongDateTotalView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } xyGraph.setSize(r.width, r.height); } public void controlMoved(ControlEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(true); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); traceDataProvider = new CircularBufferDataProvider(true); // traceDataProvider.setBufferSize(buffer); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); // create the trace trace = new Trace("TOTAL", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); trace.getXAxis().setFormatPattern("yyyy-MM-dd\n HH:mm:ss"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); trace.setTraceType(TraceType.AREA); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); // add the trace to xyGraph xyGraph.addTrace(trace); ChartUtil.addSolidLine(xyGraph, traceDataProvider, ColorUtil.getInstance().TOTAL_CHART_COLOR); ScouterUtil.addShowTotalValueListener(canvas, xyGraph); man = getViewSite().getActionBars().getToolBarManager(); canvas.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F5) { ExUtil.asyncRun( new Runnable() { public void run() { try { setInput(sDate, eDate, objType, counter, serverId); } catch (Exception e) { e.printStackTrace(); } } }); } } }); man.add( new Action("Reload", ImageUtil.getImageDescriptor(Images.refresh)) { public void run() { ExUtil.exec( new Runnable() { public void run() { try { setInput(sDate, eDate, objType, counter, serverId); } catch (Exception e) { e.printStackTrace(); } } }); } }); man.add(new Separator()); man.add( new Action("Duplicate", ImageUtil.getImageDescriptor(Images.copy)) { public void run() { ExUtil.exec( new Runnable() { public void run() { duplicateView(); } }); } }); restoreState(); }
protected void buildBars() { long now = TimeUtil.getCurrentTime(); if ((now - lastDrawTime) < REFRESH_INTERVAL || area == null) { return; } if (onGoing) return; onGoing = true; int width = area.width > 100 ? area.width : 100; int height = area.height > 50 ? area.height : 50; Image img = new Image(null, width, height); GC gc = new GC(img); try { lastDrawTime = now; double maxValue = 0; ArrayList<EqData> list = new ArrayList<EqData>(); synchronized (valueSet) { for (EqData e : valueSet) { if (objSelMgr.isUnselectedObject(e.objHash)) { continue; } double max = ChartUtil.getEqMaxValue(e.asd.act1 + e.asd.act2 + e.asd.act3); if (max > maxValue) { maxValue = max; } list.add(e); } } size = list.size(); if (size < 1) { datas = new EqData[0]; return; } datas = list.toArray(new EqData[size]); unitHeight = (height - AXIS_PADDING) / size; if (unitHeight < MINIMUM_UNIT_HEIGHT) { unitHeight = MINIMUM_UNIT_HEIGHT; } // draw horizontal line gc.setForeground(XLogViewPainter.color_grid_narrow); gc.setLineStyle(SWT.LINE_DOT); for (int i = AXIS_PADDING + unitHeight; i <= height - unitHeight; i = i + unitHeight) { gc.drawLine(0, i, width, i); } // draw axis line gc.setForeground(black); gc.setLineStyle(SWT.LINE_SOLID); int verticalLineX = 6; gc.drawLine(verticalLineX, AXIS_PADDING, verticalLineX, height); gc.drawLine(verticalLineX, AXIS_PADDING, width, AXIS_PADDING); int groundWidth = area.width - verticalLineX; int barSpace = width - verticalLineX - (3 * BAR_WIDTH); int imgHeight = unitHeight - (BAR_PADDING_HEIGHT * 2); int mod = (int) (TimeUtil.getCurrentTime() % CYCLE_INTERVAL); for (int i = 0; i < datas.length; i++) { // draw objName String objName = datas[i].displayName; gc.setForeground(dark_gary); gc.setFont(verdana10Italic); int strWidth = gc.stringExtent(objName).x; while (groundWidth <= (strWidth + 5)) { objName = objName.substring(1); strWidth = gc.stringExtent(objName).x; } int x1 = width - strWidth - 5; int y1 = AXIS_PADDING + (unitHeight * i) + ((unitHeight - (gc.stringExtent(objName).y + 2))); gc.drawString(objName, x1, y1, true); if (datas[i].isAlive == false) { gc.setForeground(dark_gary); gc.setLineWidth(2); gc.drawLine( x1 - 1, y1 + (gc.stringExtent(objName).y / 2), x1 + gc.stringExtent(objName).x + 1, y1 + (gc.stringExtent(objName).y / 2)); } gc.setLineWidth(1); ActiveSpeedData asd = datas[i].asd; long total = asd.act1 + asd.act2 + asd.act3; double reach = barSpace * (total / maxValue); int barX = verticalLineX + 1; if (total > 0) { try { // distribute bars to 3 types int noOfBars = (int) reach / BAR_WIDTH; int noOfAct1 = (int) (noOfBars * ((double) asd.act1 / total)); int noOfAct2 = (int) (noOfBars * ((double) asd.act2 / total)); int noOfAct3 = (int) (noOfBars * ((double) asd.act3 / total)); int sediments = noOfBars - (noOfAct1 + noOfAct2 + noOfAct3); while (sediments > 0) { if (asd.act3 > 0) { noOfAct3++; sediments--; } if (sediments > 0 && asd.act2 > 0) { noOfAct2++; sediments--; } if (sediments > 0 && asd.act1 > 0) { noOfAct1++; sediments--; } } int barY = AXIS_PADDING + ((unitHeight * i) + BAR_PADDING_HEIGHT); Color lastColor = null; for (int j = 0; j < noOfAct3; j++) { // draw red bar drawNemo( gc, ColorUtil.getInstance().ac3, barX + 1, barY + 1, BAR_WIDTH - 2, imgHeight - 2); barX += BAR_WIDTH; lastColor = ColorUtil.getInstance().ac3; } for (int j = 0; j < noOfAct2; j++) { // draw yellow bar drawNemo( gc, ColorUtil.getInstance().ac2, barX + 1, barY + 1, BAR_WIDTH - 2, imgHeight - 2); barX += BAR_WIDTH; lastColor = ColorUtil.getInstance().ac2; } for (int j = 0; j < noOfAct1; j++) { // draw blue bar drawNemo( gc, ColorUtil.getInstance().ac1, barX + 1, barY + 1, BAR_WIDTH - 2, imgHeight - 2); barX += BAR_WIDTH; lastColor = ColorUtil.getInstance().ac1; } // draw tong-tong bar if (lastColor != null) { drawNemo( gc, lastColor, barX + 1 + (int) calculateReach(mod, BAR_WIDTH * 0.7d), barY + 1, BAR_WIDTH - 2, imgHeight - 2); } } catch (Throwable th) { th.printStackTrace(); } } // draw count text if (datas[i].isAlive) { gc.setFont(verdana10Bold); gc.setForeground(black); String v = Long.toString(total); gc.drawString( v, barX + (BAR_WIDTH * 2), AXIS_PADDING + (unitHeight * i) + ((unitHeight - gc.stringExtent(v).y) / 2), true); } } // draw scale text gc.setForeground(black); gc.setFont(verdana7); int max = (int) maxValue; String v = Integer.toString(max); String v2 = Integer.toString(max / 2); gc.drawString(v, width - gc.stringExtent(v).x - 2, 2, true); gc.drawString( v2, verticalLineX + ((width - verticalLineX) / 2) - gc.stringExtent(v2).x, 2, true); gc.drawString("0", verticalLineX, 2, true); } catch (Throwable th) { th.printStackTrace(); } finally { gc.dispose(); Image old = ibuffer; ibuffer = img; if (old != null) { old.dispose(); } onGoing = false; } }