work on charts

This commit is contained in:
7u83 2017-09-30 22:04:13 +02:00
parent a1774aeded
commit 254846c356
5 changed files with 23 additions and 16 deletions

View File

@ -1,4 +1,4 @@
#Sat, 30 Sep 2017 20:42:29 +0200
#Sat, 30 Sep 2017 21:57:38 +0200
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=

View File

@ -115,8 +115,11 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
this.xbar.setMaximum(994000);
ChartPainter p = new ChartPainter();
p.drawChart((Graphics2D)g, xbar, getSize());
drawChart((Graphics2D)g);
//drawChart((Graphics2D)g);
}
/**
@ -148,7 +151,7 @@ public class Chart1 extends javax.swing.JPanel implements QuoteReceiver, Adjustm
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
System.out.printf("Adjustemntlistener called %d\n",xbar.getValue());
this.repaint();
}

View File

@ -25,6 +25,8 @@
*/
package chart;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.swing.JScrollBar;
@ -36,16 +38,18 @@ public class ChartPainter {
int em_width;
final void init(Graphics2D g) {
protected final void init(Graphics2D g) {
// Calculate the number of pixels for 1 em
em_width = g.getFontMetrics().stringWidth("M");
}
public void drawChart(Graphics2D g, JScrollBar sb) {
public void drawChart(Graphics2D g, JScrollBar sb, Dimension size) {
init (g);
g.setColor(Color.MAGENTA);
g.drawLine(0, 0, size.width, 100);
g.setBackground(Color.yellow);
}

View File

@ -44,10 +44,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="chart11" min="-2" pref="157" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="53" max="-2" attributes="0"/>
<Component id="jToolBar1" min="-2" pref="25" max="-2" attributes="0"/>
<EmptySpace pref="89" max="32767" attributes="0"/>
<Component id="chart11" min="-2" pref="198" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jToolBar1" pref="102" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jScrollBar1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -70,7 +70,7 @@
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="157" max="32767" attributes="0"/>
<EmptySpace min="0" pref="198" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>

View File

@ -69,7 +69,7 @@ public class ChartTestDialog extends javax.swing.JDialog {
);
chart11Layout.setVerticalGroup(
chart11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 157, Short.MAX_VALUE)
.addGap(0, 198, Short.MAX_VALUE)
);
jToolBar1.setFloatable(false);
@ -91,10 +91,10 @@ public class ChartTestDialog extends javax.swing.JDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(chart11, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53)
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
.addComponent(chart11, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);