public void createPartControl(Composite parent) { String displayCounter = defaultServer.getCounterEngine().getCounterDisplayName(objType, counter); String objectDisplay = defaultServer.getCounterEngine().getDisplayNameObjectType(objType); setPartName(grpName + " - " + displayCounter); mode = CounterUtil.getTotalMode(objType, counter); desc = grpName + " | (Today) [" + objectDisplay + "] " + displayCounter; GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; parent.setLayout(layout); parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); parent.setBackgroundMode(SWT.INHERIT_FORCE); canvas = new FigureCanvas(parent); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); 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)) { CounterTodayGroupCountView.this.setContentDescription(desc); } else { CounterTodayGroupCountView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } if (xyGraph == null) return; xyGraph.setSize(r.width, r.height); lineWidth = r.width / 30; trace.setLineWidth(lineWidth); xAxisUnitWidth = xyGraph.primaryXAxis.getValuePosition(1, false) - xyGraph.primaryXAxis.getValuePosition(0, false); } public void controlMoved(ControlEvent e) {} }); canvas.addMouseListener( new MouseListener() { public void mouseUp(MouseEvent e) { writedValueMode = false; canvas.redraw(); } public void mouseDown(MouseEvent e) { writeValue(e.x); } public void mouseDoubleClick(MouseEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(false); xyGraph.primaryXAxis.setShowMajorGrid(false); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); traceDataProvider = new CircularBufferDataProvider(true); traceDataProvider.setBufferSize(24); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); this.xyGraph.primaryXAxis.setRange(0, 24); // create the trace trace = new Trace("TotalCount", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); // trace.getXAxis().setFormatPattern("HH"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(15); trace.setTraceType(TraceType.BAR); trace.setAreaAlpha(200); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); // add the trace to xyGraph xyGraph.addTrace(trace); thread = new RefreshThread(this, 5000); thread.start(); thread.setName( this.toString() + " - " + "objType:" + objType + ", counter:" + counter + ", grpName:" + grpName); }
public void createPartControl(Composite parent) { GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; parent.setLayout(layout); parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); parent.setBackgroundMode(SWT.INHERIT_FORCE); window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); man = getViewSite().getActionBars().getToolBarManager(); man.add( new Action("Reload", ImageUtil.getImageDescriptor(Images.refresh)) { public void run() { yesterday = null; yesterdayDataProvider.clearTrace(); traceDataProvider.clearTrace(); thread.interrupt(); } }); canvas = new FigureCanvas(parent); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); 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)) { CounterTodayTotalView.this.setContentDescription(desc); } else { CounterTodayTotalView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } xyGraph.setSize(r.width, r.height); } public void controlMoved(ControlEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); // xyGraph.setShowTitle(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(""); ScouterUtil.addShowTotalValueListener(canvas, xyGraph); createDataProvider(); createYesterdayProvider(); canvas.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F5) { yesterday = null; yesterdayDataProvider.clearTrace(); traceDataProvider.clearTrace(); thread.interrupt(); } } }); String date = DateUtil.yyyymmdd(TimeUtil.getCurrentTime(serverId)); 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 + " | (Today) [" + date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + "] Total " + counterDisplay + (!"".equals(counterUnit) ? " (" + counterUnit + ")" : ""); try { setViewTab(objType, counter, serverId); } catch (Exception e1) { e1.printStackTrace(); } thread = new RefreshThread(this, 10000); thread.setName( this.toString() + " - " + "objType:" + objType + ", counter:" + counter + ", serverId:" + serverId); thread.start(); }