1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
@JenSoftView(background = DarkViewBackground.class, description = "Area with multiple lines based on line x function")
public class AreaMultipleLineXFunction extends View2D {
// source functions
//Cadence
double[] xValues1 = {0};
double[] yValues1 = {0};
int i;
int maxX=6;
int maxY=100;
public AreaMultipleLineXFunction() {
super(50);
}
public void genererGraphique() {
UserSourceFunction source1 = new UserSourceFunction.LineSource(xValues1, yValues1);
//x1, X2 y1, y2
Window2D window = new Window2D.Linear(0, maxX, 0, maxY);
registerWindow2D(window);
window.setThemeColor(RosePalette.LEMONPEEL);
// device outline plug-in
window.registerPlugin(new OutlinePlugin());
Font font = new Font("lucida console", Font.PLAIN, 10);
// create modeled axis plug-in in south part
AxisMetricsPlugin.ModeledMetrics southMetrics = new AxisMetricsPlugin.ModeledMetrics.S();
window.registerPlugin(southMetrics);
southMetrics.setMetricsFont(font);
southMetrics.registerMetricsModels(MetricsModelRangeCollections.NanoGiga);
// create modeled axis plug-in in west part
AxisMetricsPlugin.ModeledMetrics westMetrics = new AxisMetricsPlugin.ModeledMetrics.W();
window.registerPlugin(westMetrics);
westMetrics.setMetricsFont(font);
westMetrics.registerMetricsModels(MetricsModelRangeCollections.NanoGiga);
// area functions plug-in
AreaFunction areaPlugin = new FunctionPlugin.AreaFunction();
window.registerPlugin(areaPlugin);
Area area1 = new Area(source1);
area1.setThemeColor(PetalPalette.GRAY);
area1.setAreaDraw(new AreaDefaultDraw(Color.WHITE, new BasicStroke(1.5f), Color.WHITE, new BasicStroke(1.5f)));
area1.setAreaFill(new AreaGradientFill());
area1.setAreaBase(-3);
areaPlugin.addFunction(area1);
// legend
Legend legend = new Legend("Areas functions");
legend.setLegendFill(new LegendGradientFill(Color.WHITE, JennyPalette.JENNY8));
legend.setFont(InputFonts.getFont(InputFonts.NEUROPOL, 10));
legend.setConstraints(new LegendConstraints(LegendPosition.East, 0.3f, LegendAlignment.Rigth));
LegendPlugin legendPlugin = new LegendPlugin(legend);
window.registerPlugin(legendPlugin);
// stripe
MultiplierStripe stripePlugin = new StripePlugin.MultiplierStripe.H(0, 2.5);
StripePalette bp = new StripePalette();
bp.addPaint(new Color(255, 255, 255, 20));
bp.addPaint(ColorPalette.alpha(FilPalette.GREEN4, 20));
stripePlugin.setStripePalette(bp);
window.registerPlugin(stripePlugin);
// grid
MultiplierGrid gridLayout = new GridPlugin.MultiplierGrid(0, 2.5, GridOrientation.Horizontal);
gridLayout.setGridColor(new Color(255, 255, 255, 60));
window.registerPlugin(gridLayout);
MultiplierGrid gridLayout2 = new GridPlugin.MultiplierGrid(0, 2.5, GridOrientation.Vertical);
gridLayout2.setGridColor(new Color(255, 255, 255, 60));
window.registerPlugin(gridLayout2);
// translate
TranslatePlugin translatePlugin = new TranslatePlugin();
translatePlugin.registerContext(new TranslateDefaultDeviceContext());
window.registerPlugin(translatePlugin);
}
public double[] getxValues1() {
return xValues1;
}
public void setxValues1(double[] xValues1) {
this.xValues1 = xValues1;
}
public double[] getyValues1() {
return yValues1;
}
public void setyValues1(double[] yValues1) {
this.yValues1 = yValues1;
}
public int getMaxX() {
return maxX;
}
public void setMaxX(int maxX) {
this.maxX = maxX;
}
public int getMaxY() {
return maxY;
}
public void setMaxY(int maxY) {
this.maxY = maxY;
}
} |