xlang v4.0 Release
程序设计语言基础库文档
载入中...
搜索中...
未找到
Qt5.xcs
浏览该文件的文档.
1// xlang
2/*
3using{
4 Qt;
5};
6
7
8class MainDialog : QDialog{
9
10 QPushButton btnOk;
11 QwtPlot plot = new QwtPlot();
12 QwtPlotCurve curve = new QwtPlotCurve();
13 QwtPlotMultiBarChart m_barChartItem = nilptr;
14 public bool create()override{
15 QBuffer qb = new QBuffer();
16 byte [] buffer = __xPackageResource("ui/dialog.ui");
17 qb.setBuffer(buffer, 0, buffer.length);
18
19 if (load(qb)){
20 btnOk = (QPushButton)attachByName(new QPushButton(), "btnOk");
21 plot.create(this);
22 plot.resize(600, 350);
23 plot.move(0, 0);
24 curve.attach(plot);
25
26 btnOk.setOnClickListener(new onClickListener(){
27 void onClick(QObject obj, bool checked)override{
28 plot.setTitle("月报");
29 QwtText t = new QwtText();
30 t.setColor(0xff0000ff);
31 t.setText("金额");
32 t.setRenderFlags(RenderHint.TextAntialiasing);
33 plot.setAxisTitle(plot.Axis.yBottom, t);
34 t.setText("人数");
35
36 QwtColumnSymbol symbol = new QwtColumnSymbol(QwtColumnSymbol.Style.Box);
37
38 plot.setAxisTitle(plot.Axis.yLeft, t);
39 QBrush br;
40
41 plot.setCanvasBackground(0xff3F5FCA, QBrush.Style.SolidPattern);
42 curve.setTitle("卧槽");
43 curve.setPen(0xff00ff00, 2);
44 curve.setCurveAttribute(QwtPlotCurve.CurveAttribute.Fitted, true);
45 curve.setRenderHint(QwtPlotItem.RenderAntialiased,true);
46 curve.setSamples(new float [] {1,1,2,2,3,3,4,4,5,5,6,6,7,100,1,1,2,2,3,3,4,4,5,5,6,6,7,7}, 28);
47
48 QwtScaleDraw q = new QwtScaleDraw(){
49 public QwtText label( double value ) {
50 return new QwtText("我凑:" + (int)value);
51 }
52 };
53
54 plot.setAxisScaleDraw(plot.Axis.yLeft, q);
55 plot.setAxisScaleDraw(plot.Axis.yBottom, new QwtScaleDraw(){
56 public QwtText label( double value ) {
57 return new QwtText("马德:" + (int)value);
58 }
59 });
60
61 QwtPlotMarker m = new QwtPlotMarker("fuck");
62 t.setText("fuck");
63 m.setLabel(t);
64 m.setXValue(2);
65 m.setYValue(2);
66 m.attach(plot);
67 m.setLabelAlignment(Constant.AlignTop);
68
69 QwtPlotCanvas canvas = new QwtPlotCanvas();
70 canvas.create();
71 canvas.setStyleSheetString("background: rgba(255,255,255,0%); color: white;");
72 canvas.setLineWidth(0);
73 canvas.setFrameStyle((int)QFrame.Shape.Box | (int)QFrame.Shadow.Sunken );
74 canvas.setBorderRadius(0);
75 plot.setCanvas(canvas);
76
77 QwtSymbol s = new QwtSymbol(QwtSymbol.Style.Ellipse, 0xffff0000, QBrush.Style.SolidPattern, 0xff0000ff, 1, new QSize(5, 5));
78 curve.setSymbol(s);
79 QwtLegend l = new QwtLegend();
80 l.create();
81 plot.insertLegend(l, QwtPlot.LegendPosition.BottomLegend, -1.0);
82 plot.replot();
83 }
84 });
85
86 return true;
87 }
88 return false;
89 }
90};
91
92/*
93int [] colors = { SvgColor.darkorchid, SvgColor.steelblue, SvgColor.gold };
94 QwtPlotBarChart qpc = new QwtPlotBarChart("fuck"){
95 public QwtColumnSymbol specialSymbol(int sampleIndex, float x, float y) {
96 QwtColumnSymbol symbol = new QwtColumnSymbol(QwtColumnSymbol.Style.Box);
97 symbol.setLineWidth(0);
98 symbol.setFrameStyle( QwtColumnSymbol.FrameStyle.Raised );
99 if (sampleIndex > 0){
100 symbol.setPalette(colors[sampleIndex % colors.length]);
101 }
102 return symbol;
103 }
104
105 public QwtText barTitle( int sampleIndex ) {
106 return new QwtText("g" + sampleIndex);
107 }
108 };
109
110 qpc.setSamples(new float [] {1,1,2,2,3,3,4,4,5,5,6,6,7,7,1,1,2,2,3,3,4,4,5,5,6,6,7,7}, 28);
111 qpc.attach(plot);
112*/
113
114/*
115
116int numSamples = 5, numBars = 3;
117 Vector< Vector< float > > series = new Vector< Vector< float > >();
118 for ( int i = 0; i < numSamples; i++ )
119 {
120 Vector< float > values = new Vector< float >();
121 for ( int j = 0; j < numBars; j++ )
122 values .add ( 2 + Math.random() * 8 );
123
124 series.add( values );
125 }
126
127 m_barChartItem = new QwtPlotMultiBarChart("Bar Chart ");
128 m_barChartItem.setLayoutPolicy(QwtPlotMultiBarChart.LayoutPolicy.AutoAdjustSamples );
129 m_barChartItem.setSpacing( 40 );
130 m_barChartItem.setMargin( 0 );
131
132 m_barChartItem.attach( plot );
133 int [] colors = { SvgColor.darkorchid, SvgColor.steelblue, SvgColor.gold };
134 for ( int i = 0; i < numBars; i++ )
135 {
136 QwtColumnSymbol symbol = new QwtColumnSymbol(QwtColumnSymbol.Style.Box);
137 symbol.setLineWidth(0);
138 symbol.setFrameStyle( QwtColumnSymbol.FrameStyle.Raised );
139 symbol.setPalette(colors[i]);
140 m_barChartItem.setSymbol( i, symbol );
141 }
142 m_barChartItem.setSamples(series);
143 //m_barChartItem.setStyle(QwtPlotMultiBarChart.ChartStyle.Grouped );
144 QwtText [] titles = new QwtText[numBars];
145 for ( int i = 0; i < numBars; i++ ){
146 titles[i] = new QwtText(String.format("Bar %d", i));
147 }
148 m_barChartItem.setBarTitles( titles );
149
150*/
151/*
152 QwtLegend l = new QwtLegend();
153 l.create();
154 l.setMaxColumns(1);
155 //l.setWindowTitle("卧槽");
156 plot.insertLegend(l, QwtPlot.LegendPosition.BottomLegend, -1.0);
157
158 plot.setAxisTitle(plot.Axis.yLeft, t);
159 QBrush br;
160
161 plot.setCanvasBackground(0xff3F5FCA, QBrush.Style.SolidPattern);
162 curve.setTitle("卧槽");
163 curve.setPen(0xff00ff00, 2);
164 curve.setRenderHint(QwtPlotItem.RenderAntialiased,true);
165 curve.setSamples(new float [] {1,1,2,2,3,3,4,4,5,5,6,6,7,7,1,1,2,2,3,3,4,4,5,5,6,6,7,7}, 28);
166 curve.attach(plot);
167 QwtScaleDraw q = new QwtScaleDraw(){
168 public QwtText label( double value ) {
169 return new QwtText("我凑:" + value);
170 }
171 };
172 plot.setAxisScaleDraw(plot.Axis.yLeft, q);
173 plot.setAxisScaleDraw(plot.Axis.yBottom, new QwtScaleDraw(){
174 public QwtText label( double value ) {
175 return new QwtText("马德:" + value);
176 }
177 });
178 QwtPlotMarker m = new QwtPlotMarker("fuck");
179 t.setText("fuck");
180 m.setLabel(t);
181 m.setXValue(2);
182 m.setYValue(2);
183 m.attach(plot);
184 m.setLabelAlignment(Constant.AlignTop);
185
186 QwtPlotCanvas canvas = new QwtPlotCanvas();
187 canvas.create();
188 canvas.setLineWidth( 0 );
189 canvas.setFrameStyle((int)QFrame.Shape.Box | (int)QFrame.Shadow.Sunken );
190 canvas.setBorderRadius( 0 );
191 plot.setCanvas(canvas);
192 QwtSymbol s = new QwtSymbol(QwtSymbol.Style.Ellipse, 0xffff0000, QBrush.Style.SolidPattern, 0xff0000ff, 1, new QSize(5, 5));
193 curve.setSymbol(s);
194
195*/
196
197/*
198class XMyApp : QApplication {
199
200 MainDialog dialog;
201
202 public bool create(){
203 if (super.createQApplication()){
204 dialog = new MainDialog();
205 if (dialog.create()){
206 dialog.show();
207 return true;
208 }
209 }
210 return false;
211 }
212
213};
214
215
216int main(String [] args){
217
218 return 0;
219}
220*/