本文整理汇总了Java中org.jfree.chart.plot.CategoryMarker类的典型用法代码示例。如果您正苦于以下问题:Java CategoryMarker类的具体用法?Java CategoryMarker怎么用?Java CategoryMarker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CategoryMarker类属于org.jfree.chart.plot包,在下文中一共展示了CategoryMarker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetSetKey
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Some checks for the getKey() and setKey() methods.
*/
public void testGetSetKey() {
CategoryMarker m = new CategoryMarker("X");
m.addChangeListener(this);
this.lastEvent = null;
assertEquals("X", m.getKey());
m.setKey("Y");
assertEquals("Y", m.getKey());
assertEquals(m, this.lastEvent.getMarker());
// check null argument...
try {
m.setKey(null);
fail("Expected an IllegalArgumentException for null.");
}
catch (IllegalArgumentException e) {
assertTrue(true);
}
}
示例2: testListenersWithCategoryPlot
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Checks that a CategoryPlot deregisters listeners when clearing markers.
*/
public void testListenersWithCategoryPlot() {
CategoryPlot plot = new CategoryPlot();
CategoryMarker marker1 = new CategoryMarker("X");
ValueMarker marker2 = new ValueMarker(1.0);
plot.addDomainMarker(marker1);
plot.addRangeMarker(marker2);
EventListener[] listeners1 = marker1.getListeners(
MarkerChangeListener.class);
assertTrue(Arrays.asList(listeners1).contains(plot));
EventListener[] listeners2 = marker1.getListeners(
MarkerChangeListener.class);
assertTrue(Arrays.asList(listeners2).contains(plot));
plot.clearDomainMarkers();
plot.clearRangeMarkers();
listeners1 = marker1.getListeners(MarkerChangeListener.class);
assertFalse(Arrays.asList(listeners1).contains(plot));
listeners2 = marker1.getListeners(MarkerChangeListener.class);
assertFalse(Arrays.asList(listeners2).contains(plot));
}
示例3: setMarkers
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void setMarkers(final CategoryPlot plot, final Map params) {
final Marker[] domainMarkers = (Marker[]) params.get("domainMarkers");
// this method may be extended for range markers in future.
if (domainMarkers != null && domainMarkers.length > 0) {
for (final Marker marker : domainMarkers) {
final CategoryMarker cmarker = (CategoryMarker) marker;
cmarker.setDrawAsLine(true);
if (cmarker.getLabel() != null) {
cmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
cmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
}
plot.addDomainMarker(cmarker);
}
}
}
示例4: testGetSetKey
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Some checks for the getKey() and setKey() methods.
*/
public void testGetSetKey() {
CategoryMarker m = new CategoryMarker("X");
m.addChangeListener(this);
this.lastEvent = null;
assertEquals("X", m.getKey());
m.setKey("Y");
assertEquals("Y", m.getKey());
assertEquals(m, this.lastEvent.getMarker());
// check null argument...
try {
m.setKey(null);
fail("Expected an IllegalArgumentException for null.");
}
catch (IllegalArgumentException e) {
assertTrue(true);
}
}
示例5: testGetSetDrawAsLine
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Some checks for the getDrawAsLine() and setDrawAsLine() methods.
*/
public void testGetSetDrawAsLine() {
CategoryMarker m = new CategoryMarker("X");
m.addChangeListener(this);
this.lastEvent = null;
assertEquals(false, m.getDrawAsLine());
m.setDrawAsLine(true);
assertEquals(true, m.getDrawAsLine());
assertEquals(m, this.lastEvent.getMarker());
}
示例6: testAddDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Some tests for the addDomainMarker() method(s).
*/
public void testAddDomainMarker() {
CategoryPlot plot = new CategoryPlot();
CategoryMarker m = new CategoryMarker("C1");
plot.addDomainMarker(m);
List listeners = Arrays.asList(m.getListeners(
MarkerChangeListener.class));
assertTrue(listeners.contains(plot));
plot.clearDomainMarkers();
listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class));
assertFalse(listeners.contains(plot));
}
示例7: addMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
@Override
protected void addMarker(Plot plot, Marker marker)
{
((CategoryPlot)plot).addDomainMarker(
(CategoryMarker)marker,
getLayer()
);
}
示例8: createMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
protected CategoryMarker createMarker(JRChart jrc)
{
Comparable<?> value = getProperty(PROPERTY_CATEGORY);
if (value == null)
{
return null;
}
CategoryMarker marker = new CategoryMarker(value);
configureMarker(marker);
configureStroke(marker);
Boolean drawAsLine = getBooleanProperty(PROPERTY_DRAW_AS_LINE);
if (drawAsLine != null) {
marker.setDrawAsLine(drawAsLine);
}
//Setup the font
Font font = marker.getLabelFont();
String fontName = getProperty(PROPERTY_FONT_NAME);
if (fontName == null) {
fontName = font.getName();
}
Float fontSize = getFloatProperty(PROPERTY_FONT_SIZE);
if (fontSize == null) {
fontSize = Float.valueOf(font.getSize());
}
int fontStyle = Font.PLAIN;
Boolean isBold = getBooleanProperty(PROPERTY_FONT_BOLD);
if (isBold != null) {
fontStyle = fontStyle | Font.BOLD;
}
Boolean isItalic = getBooleanProperty(PROPERTY_FONT_ITALIC);
if (isItalic != null) {
fontStyle = fontStyle | Font.ITALIC;
}
marker.setLabelFont(
FontUtil.getInstance(filler.getJasperReportsContext()).getAwtFontFromBundles(
fontName,
fontStyle,
fontSize,
filler.getFillContext().getMasterLocale(),
true
)
);
return marker;
}
示例9: createChart
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return a sample chart.
*/
protected JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
chartTitle, // chart title
domainLabel, // domain axis label
rangeLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
!legendPanelOn, // include legend
true,
false
);
chart.setBackgroundPaint(Color.lightGray);
// get a reference to the plot for further customisation...
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setNoDataMessage("NO DATA!");
CategoryItemRenderer renderer = new CustomBarRenderer(
new Paint[] {Color.red, Color.blue, Color.green,
Color.yellow, Color.orange, Color.cyan,
Color.magenta, Color.blue}
);
renderer.setBaseItemLabelGenerator(
new StandardCategoryItemLabelGenerator()
);
renderer.setBaseItemLabelsVisible(true);
ItemLabelPosition p = new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0
);
renderer.setBasePositiveItemLabelPosition(p);
plot.setRenderer(renderer);
CategoryMarker marker = new CategoryMarker("Category 3");
marker.setLabel("Special");
marker.setPaint(new Color(0xDD, 0xFF, 0xDD, 0x80));
marker.setAlpha(0.5f);
marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
plot.addDomainMarker(marker, Layer.BACKGROUND);
// change the margin at the top of the range axis...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setLowerMargin(0.15);
rangeAxis.setUpperMargin(0.15);
BarRenderer seriesRenderer = (BarRenderer) plot.getRenderer();
seriesRenderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
setCategorySummary(dataset);
return chart;
}
示例10: addDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
public void addDomainMarker(CategoryPlot plot, cfCHARTDOMAINMARKERData dmData) throws cfmRunTimeException {
CategoryMarker domainMarker = new CategoryMarker(dmData.getValue());
boolean drawAsLine = false;
if (dmData.getShape().equals("line"))
drawAsLine = true;
domainMarker.setDrawAsLine(drawAsLine);
domainMarker.setPaint(convertStringToColor(dmData.getColor()));
if (dmData.getLabel() != null) {
domainMarker.setLabel(dmData.getLabel());
domainMarker.setLabelPaint(convertStringToColor(dmData.getLabelColor()));
String labelPos = dmData.getLabelPosition();
if (labelPos.equals("top_left")) {
domainMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
else
domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
} else if (labelPos.equals("top")) {
domainMarker.setLabelAnchor(RectangleAnchor.TOP);
domainMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
} else if (labelPos.equals("top_right")) {
domainMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
else
domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
} else if (labelPos.equals("left")) {
domainMarker.setLabelAnchor(RectangleAnchor.LEFT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
else
domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
} else if (labelPos.equals("center")) {
domainMarker.setLabelAnchor(RectangleAnchor.CENTER);
domainMarker.setLabelTextAnchor(TextAnchor.CENTER);
} else if (labelPos.equals("right")) {
domainMarker.setLabelAnchor(RectangleAnchor.RIGHT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
else
domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT);
} else if (labelPos.equals("bottom_left")) {
domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
else
domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
} else if (labelPos.equals("bottom")) {
domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER);
} else if (labelPos.equals("bottom_right")) {
domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
if (drawAsLine)
domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
else
domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
}
domainMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE);
domainMarker.setLabelFont(getFont(dmData.getFont(), dmData.getFontBold(), dmData.getFontItalic(), dmData.getFontSize()));
}
plot.addDomainMarker(domainMarker, Layer.BACKGROUND);
}
示例11: testCloning
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Confirm that cloning works.
*/
public void testCloning() {
CategoryPlot p1 = new CategoryPlot();
p1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white,
3.0f, 4.0f, Color.yellow));
p1.setRangeMinorGridlinePaint(new GradientPaint(2.0f, 3.0f, Color.white,
4.0f, 5.0f, Color.red));
p1.setRangeZeroBaselinePaint(new GradientPaint(3.0f, 4.0f, Color.red,
5.0f, 6.0f, Color.white));
CategoryPlot p2 = null;
try {
p2 = (CategoryPlot) p1.clone();
}
catch (CloneNotSupportedException e) {
e.printStackTrace();
System.err.println("Failed to clone.");
}
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
// check independence
p1.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0,
Color.red, new BasicStroke(1.0f)));
assertFalse(p1.equals(p2));
p2.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0,
Color.red, new BasicStroke(1.0f)));
assertTrue(p1.equals(p2));
p1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND);
assertFalse(p1.equals(p2));
p2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND);
assertTrue(p1.equals(p2));
p1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND);
assertFalse(p1.equals(p2));
p2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND);
assertTrue(p1.equals(p2));
p1.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND);
assertFalse(p1.equals(p2));
p2.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND);
assertTrue(p1.equals(p2));
p1.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND);
assertFalse(p1.equals(p2));
p2.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND);
assertTrue(p1.equals(p2));
}
示例12: testRemoveDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Check that removing a marker that isn't assigned to the plot returns
* false.
*/
public void testRemoveDomainMarker() {
CategoryPlot plot = new CategoryPlot();
assertFalse(plot.removeDomainMarker(new CategoryMarker("Category 1")));
}
示例13: drawDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Draws a line (or some other marker) to indicate a particular category on
* the domain axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the category axis.
* @param marker the marker.
* @param dataArea the area for plotting data (not including 3D effect).
*
* @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
* Rectangle2D)
*/
public void drawDomainMarker(Graphics2D g2,
CategoryPlot plot,
CategoryAxis axis,
CategoryMarker marker,
Rectangle2D dataArea);
示例14: drawDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Draws a line (or some other marker) to indicate a particular category on
* the domain axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the category axis.
* @param marker the marker.
* @param dataArea the area for plotting data (not including 3D effect).
*
* @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
* Rectangle2D)
*/
public void drawDomainMarker(Graphics2D g2, CategoryPlot plot,
CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea);
示例15: drawDomainMarker
import org.jfree.chart.plot.CategoryMarker; //导入依赖的package包/类
/**
* Draws a line (or some other marker) to indicate a particular category on
* the domain axis.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the category axis.
* @param marker the marker.
* @param dataArea the area for plotting data.
*
* @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
* Rectangle2D)
*/
public void drawDomainMarker(Graphics2D g2, CategoryPlot plot,
CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea);