public void initializeLimits(Graphics2D g2d) { FontRenderContext frc = g2d.getFontRenderContext(); ImageParameters im = new ImageParameters(); int summaryLines = withSummary ? 5 : 0; im.xsize = getWidth(); im.ysize = getHeight(); im.unitslength = DEFAULT_UNITS_LENGTH; im.xorigin = (int) (PADDING_LEFT + im.unitslength * getSmallFontCharWidth(frc)); im.xorigin += getSmallFontHeight(frc); im.yorigin = PADDING_TOP + im.ysize; if(graphTitle != null && !"".equals(graphTitle)) im.yorigin += getLargeFontHeight(frc) + PADDING_TITLE; im.xgif = PADDING_RIGHT + im.xsize + im.xorigin; im.ygif = im.yorigin + (int) (PADDING_PLOT * getSmallFontHeight(frc)); im.ygif += ((int) getSmallLeading(frc) + summaryLines) * (getLegendLines() + summaryLines); im.ygif += PADDING_BOTTOM; setDimension(im.ygif, im.xgif); }
public RrdGraphDef getEmptyGraphDef() { RrdGraphDef retValue = new RrdGraphDef(); if(!Double.isNaN(lowerLimit)) retValue.setMinValue(lowerLimit); if(!Double.isNaN(upperLimit)) retValue.setMaxValue(upperLimit); if(verticalLabel != null) retValue.setVerticalLabel(verticalLabel); if(this.siUnit) retValue.setBase(1000); else retValue.setBase(1024); if(unitExponent != null) { retValue.setUnitsExponent(unitExponent); } retValue.setLogarithmic(logarithmic); retValue.setPoolUsed(true); retValue.setAntiAliasing(true); retValue.setTextAntiAliasing(true); retValue.setImageFormat("PNG"); retValue.setWidth(getWidth()); retValue.setHeight(getHeight()); return retValue; }
@Test public void testCustomGraph() throws Exception { JrdsDocument d = Tools.parseRessource("customgraph.xml"); GraphDescBuilder gdbuild = new GraphDescBuilder(); gdbuild.setPm(Tools.makePm(testFolder)); GraphDesc gd = gdbuild.makeGraphDesc(d); Assert.assertEquals("graph name failed", "graphName", gd.getGraphName()); Assert.assertEquals("graph title failed", "", gd.getGraphTitle()); Assert.assertEquals("graph name failed", "name", gd.getName()); Assert.assertEquals("graph height invalid", 800, gd.getHeight()); Assert.assertEquals("graph width invalid", 600, gd.getWidth()); Assert.assertTrue("Lower limit is a number (not a NaN)" + gd.getUpperLimit(), Double.isNaN(gd.getUpperLimit())); Assert.assertEquals("graph lower limit is invalid", 1000, gd.getLowerLimit(), 0.1); Assert.assertFalse("graph is with legend", gd.withLegend()); Assert.assertFalse("graph is with summary", gd.withSummary()); Assert.assertEquals("legend count failed", 0, gd.getLegendLines()); }