mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
FlatAnimatorTest:
- support synchronized line chart - LineChartPanel: added slider to change horizontal scaling - FlatAnimatedIconTest: added line chart panel - FlatAnimatedBorderTest: added line chart panel
This commit is contained in:
@@ -37,6 +37,14 @@ import net.miginfocom.swing.*;
|
|||||||
public class FlatAnimatedBorderTest
|
public class FlatAnimatedBorderTest
|
||||||
extends FlatTestPanel
|
extends FlatTestPanel
|
||||||
{
|
{
|
||||||
|
private static final Color CHART_FADE_1 = Color.blue;
|
||||||
|
private static final Color CHART_FADE_2 = Color.red;
|
||||||
|
private static final Color CHART_MATERIAL_1 = Color.green;
|
||||||
|
private static final Color CHART_MATERIAL_2 = Color.magenta;
|
||||||
|
private static final Color CHART_MINIMAL = Color.orange;
|
||||||
|
|
||||||
|
private static final String CHART_COLOR_KEY = "chartColor";
|
||||||
|
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatAnimatedBorderTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatAnimatedBorderTest" );
|
||||||
@@ -47,25 +55,43 @@ public class FlatAnimatedBorderTest
|
|||||||
FlatAnimatedBorderTest() {
|
FlatAnimatedBorderTest() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
textField5.setBorder( new AnimatedFocusFadeBorder() );
|
fade1TextField.setBorder( new AnimatedFocusFadeBorder() );
|
||||||
textField6.setBorder( new AnimatedFocusFadeBorder() );
|
fade2TextField.setBorder( new AnimatedFocusFadeBorder() );
|
||||||
|
|
||||||
textField1.setBorder( new AnimatedMaterialBorder() );
|
material1TextField.setBorder( new AnimatedMaterialBorder() );
|
||||||
textField2.setBorder( new AnimatedMaterialBorder() );
|
material2TextField.setBorder( new AnimatedMaterialBorder() );
|
||||||
|
|
||||||
textField4.setBorder( new AnimatedMinimalTestBorder() );
|
minimalTextField.setBorder( new AnimatedMinimalTestBorder() );
|
||||||
|
|
||||||
|
fade1TextField.putClientProperty( CHART_COLOR_KEY, CHART_FADE_1 );
|
||||||
|
fade2TextField.putClientProperty( CHART_COLOR_KEY, CHART_FADE_2 );
|
||||||
|
material1TextField.putClientProperty( CHART_COLOR_KEY, CHART_MATERIAL_1 );
|
||||||
|
material2TextField.putClientProperty( CHART_COLOR_KEY, CHART_MATERIAL_2 );
|
||||||
|
minimalTextField.putClientProperty( CHART_COLOR_KEY, CHART_MINIMAL );
|
||||||
|
|
||||||
|
fade1ChartColor.setForeground( CHART_FADE_1 );
|
||||||
|
fade2ChartColor.setForeground( CHART_FADE_2 );
|
||||||
|
material1ChartColor.setForeground( CHART_MATERIAL_1 );
|
||||||
|
material2ChartColor.setForeground( CHART_MATERIAL_2 );
|
||||||
|
minimalChartColor.setForeground( CHART_MINIMAL );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
label3 = new JLabel();
|
label3 = new JLabel();
|
||||||
textField5 = new JTextField();
|
lineChartPanel = new FlatAnimatorTest.LineChartPanel();
|
||||||
textField6 = new JTextField();
|
fade1TextField = new JTextField();
|
||||||
|
fade1ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
|
fade2TextField = new JTextField();
|
||||||
|
fade2ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
label2 = new JLabel();
|
label2 = new JLabel();
|
||||||
textField1 = new JTextField();
|
material1TextField = new JTextField();
|
||||||
textField2 = new JTextField();
|
material1ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
|
material2TextField = new JTextField();
|
||||||
|
material2ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
label1 = new JLabel();
|
label1 = new JLabel();
|
||||||
textField4 = new JTextField();
|
minimalTextField = new JTextField();
|
||||||
|
minimalChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
durationLabel = new JLabel();
|
durationLabel = new JLabel();
|
||||||
durationField = new JSpinner();
|
durationField = new JSpinner();
|
||||||
|
|
||||||
@@ -73,6 +99,8 @@ public class FlatAnimatedBorderTest
|
|||||||
setLayout(new MigLayout(
|
setLayout(new MigLayout(
|
||||||
"insets dialog,hidemode 3",
|
"insets dialog,hidemode 3",
|
||||||
// columns
|
// columns
|
||||||
|
"[fill]" +
|
||||||
|
"[fill]para" +
|
||||||
"[fill]",
|
"[fill]",
|
||||||
// rows
|
// rows
|
||||||
"[]" +
|
"[]" +
|
||||||
@@ -89,19 +117,25 @@ public class FlatAnimatedBorderTest
|
|||||||
//---- label3 ----
|
//---- label3 ----
|
||||||
label3.setText("Fade:");
|
label3.setText("Fade:");
|
||||||
add(label3, "cell 0 0");
|
add(label3, "cell 0 0");
|
||||||
add(textField5, "cell 0 1");
|
add(lineChartPanel, "cell 2 0 1 10");
|
||||||
add(textField6, "cell 0 2");
|
add(fade1TextField, "cell 0 1");
|
||||||
|
add(fade1ChartColor, "cell 1 1");
|
||||||
|
add(fade2TextField, "cell 0 2");
|
||||||
|
add(fade2ChartColor, "cell 1 2");
|
||||||
|
|
||||||
//---- label2 ----
|
//---- label2 ----
|
||||||
label2.setText("Material:");
|
label2.setText("Material:");
|
||||||
add(label2, "cell 0 3");
|
add(label2, "cell 0 3");
|
||||||
add(textField1, "cell 0 4");
|
add(material1TextField, "cell 0 4");
|
||||||
add(textField2, "cell 0 5");
|
add(material1ChartColor, "cell 1 4");
|
||||||
|
add(material2TextField, "cell 0 5");
|
||||||
|
add(material2ChartColor, "cell 1 5");
|
||||||
|
|
||||||
//---- label1 ----
|
//---- label1 ----
|
||||||
label1.setText("Minimal:");
|
label1.setText("Minimal:");
|
||||||
add(label1, "cell 0 6");
|
add(label1, "cell 0 6");
|
||||||
add(textField4, "cell 0 7");
|
add(minimalTextField, "cell 0 7");
|
||||||
|
add(minimalChartColor, "cell 1 7");
|
||||||
|
|
||||||
//---- durationLabel ----
|
//---- durationLabel ----
|
||||||
durationLabel.setText("Duration:");
|
durationLabel.setText("Duration:");
|
||||||
@@ -115,13 +149,19 @@ public class FlatAnimatedBorderTest
|
|||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
private JLabel label3;
|
private JLabel label3;
|
||||||
private JTextField textField5;
|
private FlatAnimatorTest.LineChartPanel lineChartPanel;
|
||||||
private JTextField textField6;
|
private JTextField fade1TextField;
|
||||||
|
private FlatAnimatorTest.JChartColor fade1ChartColor;
|
||||||
|
private JTextField fade2TextField;
|
||||||
|
private FlatAnimatorTest.JChartColor fade2ChartColor;
|
||||||
private JLabel label2;
|
private JLabel label2;
|
||||||
private JTextField textField1;
|
private JTextField material1TextField;
|
||||||
private JTextField textField2;
|
private FlatAnimatorTest.JChartColor material1ChartColor;
|
||||||
|
private JTextField material2TextField;
|
||||||
|
private FlatAnimatorTest.JChartColor material2ChartColor;
|
||||||
private JLabel label1;
|
private JLabel label1;
|
||||||
private JTextField textField4;
|
private JTextField minimalTextField;
|
||||||
|
private FlatAnimatorTest.JChartColor minimalChartColor;
|
||||||
private JLabel durationLabel;
|
private JLabel durationLabel;
|
||||||
private JSpinner durationField;
|
private JSpinner durationField;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
@@ -154,6 +194,11 @@ public class FlatAnimatedBorderTest
|
|||||||
Color color = ColorFunctions.mix( Color.red, Color.lightGray, animatedValue );
|
Color color = ColorFunctions.mix( Color.red, Color.lightGray, animatedValue );
|
||||||
FlatUIUtils.paintOutlinedComponent( g, x, y, width, height, 0, 0, 0, lw, 0,
|
FlatUIUtils.paintOutlinedComponent( g, x, y, width, height, 0, 0, 0, lw, 0,
|
||||||
null, color, null );
|
null, color, null );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -212,6 +257,11 @@ public class FlatAnimatedBorderTest
|
|||||||
g2d.fill( new Rectangle2D.Float( x2 + (width2 - lw) / 2, y2 + height2 - lh, lw, lh ) );
|
g2d.fill( new Rectangle2D.Float( x2 + (width2 - lw) / 2, y2 + height2 - lh, lw, lh ) );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -253,6 +303,11 @@ public class FlatAnimatedBorderTest
|
|||||||
|
|
||||||
g.setColor( Color.blue );
|
g.setColor( Color.blue );
|
||||||
g.fillRect( x, y + height - lh, Math.round( width * animatedValue ), lh );
|
g.fillRect( x, y + height - lh, Math.round( width * animatedValue ), lh );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8"
|
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
root: new FormRoot {
|
root: new FormRoot {
|
||||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||||
"$columnConstraints": "[fill]"
|
"$columnConstraints": "[fill][fill]para[fill]"
|
||||||
"$rowConstraints": "[][][]para[][][]para[][][grow][]"
|
"$rowConstraints": "[][][]para[][][]para[][][grow][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
@@ -15,16 +15,31 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 0"
|
"value": "cell 0 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$LineChartPanel" ) {
|
||||||
|
name: "lineChartPanel"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 2 0 1 10"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||||
name: "textField5"
|
name: "fade1TextField"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 1"
|
"value": "cell 0 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "fade1ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 1"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||||
name: "textField6"
|
name: "fade2TextField"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 2"
|
"value": "cell 0 2"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "fade2ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 2"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "label2"
|
name: "label2"
|
||||||
"text": "Material:"
|
"text": "Material:"
|
||||||
@@ -32,15 +47,25 @@ new FormModel {
|
|||||||
"value": "cell 0 3"
|
"value": "cell 0 3"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||||
name: "textField1"
|
name: "material1TextField"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 4"
|
"value": "cell 0 4"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "material1ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 4"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||||
name: "textField2"
|
name: "material2TextField"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 5"
|
"value": "cell 0 5"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "material2ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 5"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "label1"
|
name: "label1"
|
||||||
"text": "Minimal:"
|
"text": "Minimal:"
|
||||||
@@ -48,10 +73,15 @@ new FormModel {
|
|||||||
"value": "cell 0 6"
|
"value": "cell 0 6"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||||
name: "textField4"
|
name: "minimalTextField"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 7"
|
"value": "cell 0 7"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "minimalChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 7"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "durationLabel"
|
name: "durationLabel"
|
||||||
"text": "Duration:"
|
"text": "Duration:"
|
||||||
@@ -70,7 +100,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 405, 315 )
|
"size": new java.awt.Dimension( 725, 325 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ import net.miginfocom.swing.*;
|
|||||||
public class FlatAnimatedIconTest
|
public class FlatAnimatedIconTest
|
||||||
extends FlatTestPanel
|
extends FlatTestPanel
|
||||||
{
|
{
|
||||||
|
private static final Color CHART_RADIO_BUTTON_1 = Color.blue;
|
||||||
|
private static final Color CHART_RADIO_BUTTON_2 = Color.red;
|
||||||
|
private static final Color CHART_RADIO_BUTTON_3 = Color.green;
|
||||||
|
private static final Color CHART_CHECK_BOX_1 = Color.magenta;
|
||||||
|
private static final Color CHART_CHECK_BOX_2 = Color.orange;
|
||||||
|
|
||||||
|
private static final String CHART_COLOR_KEY = "chartColor";
|
||||||
|
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatAnimatedIconTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatAnimatedIconTest" );
|
||||||
@@ -50,15 +58,33 @@ public class FlatAnimatedIconTest
|
|||||||
|
|
||||||
checkBox1.setIcon( new AnimatedSwitchIcon() );
|
checkBox1.setIcon( new AnimatedSwitchIcon() );
|
||||||
checkBox2.setIcon( new AnimatedMinimalTestIcon() );
|
checkBox2.setIcon( new AnimatedMinimalTestIcon() );
|
||||||
|
|
||||||
|
radioButton1.putClientProperty( CHART_COLOR_KEY, CHART_RADIO_BUTTON_1 );
|
||||||
|
radioButton2.putClientProperty( CHART_COLOR_KEY, CHART_RADIO_BUTTON_2 );
|
||||||
|
radioButton3.putClientProperty( CHART_COLOR_KEY, CHART_RADIO_BUTTON_3 );
|
||||||
|
checkBox1.putClientProperty( CHART_COLOR_KEY, CHART_CHECK_BOX_1 );
|
||||||
|
checkBox2.putClientProperty( CHART_COLOR_KEY, CHART_CHECK_BOX_2 );
|
||||||
|
|
||||||
|
radioButton1ChartColor.setForeground( CHART_RADIO_BUTTON_1 );
|
||||||
|
radioButton2ChartColor.setForeground( CHART_RADIO_BUTTON_2 );
|
||||||
|
radioButton3ChartColor.setForeground( CHART_RADIO_BUTTON_3 );
|
||||||
|
checkBox1ChartColor.setForeground( CHART_CHECK_BOX_1 );
|
||||||
|
checkBox2ChartColor.setForeground( CHART_CHECK_BOX_2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
radioButton1 = new JRadioButton();
|
radioButton1 = new JRadioButton();
|
||||||
|
radioButton1ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
|
lineChartPanel = new FlatAnimatorTest.LineChartPanel();
|
||||||
radioButton2 = new JRadioButton();
|
radioButton2 = new JRadioButton();
|
||||||
|
radioButton2ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
radioButton3 = new JRadioButton();
|
radioButton3 = new JRadioButton();
|
||||||
|
radioButton3ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
checkBox1 = new JCheckBox();
|
checkBox1 = new JCheckBox();
|
||||||
|
checkBox1ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
checkBox2 = new JCheckBox();
|
checkBox2 = new JCheckBox();
|
||||||
|
checkBox2ChartColor = new FlatAnimatorTest.JChartColor();
|
||||||
durationLabel = new JLabel();
|
durationLabel = new JLabel();
|
||||||
durationField = new JSpinner();
|
durationField = new JSpinner();
|
||||||
|
|
||||||
@@ -66,8 +92,9 @@ public class FlatAnimatedIconTest
|
|||||||
setLayout(new MigLayout(
|
setLayout(new MigLayout(
|
||||||
"insets dialog,hidemode 3",
|
"insets dialog,hidemode 3",
|
||||||
// columns
|
// columns
|
||||||
"[]para" +
|
"[]" +
|
||||||
"[fill]",
|
"[fill]para" +
|
||||||
|
"[grow,fill]",
|
||||||
// rows
|
// rows
|
||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
@@ -81,30 +108,36 @@ public class FlatAnimatedIconTest
|
|||||||
radioButton1.setText("radio 1");
|
radioButton1.setText("radio 1");
|
||||||
radioButton1.setSelected(true);
|
radioButton1.setSelected(true);
|
||||||
add(radioButton1, "cell 0 0");
|
add(radioButton1, "cell 0 0");
|
||||||
|
add(radioButton1ChartColor, "cell 1 0");
|
||||||
|
add(lineChartPanel, "cell 2 0 1 6");
|
||||||
|
|
||||||
//---- radioButton2 ----
|
//---- radioButton2 ----
|
||||||
radioButton2.setText("radio 2");
|
radioButton2.setText("radio 2");
|
||||||
add(radioButton2, "cell 0 1");
|
add(radioButton2, "cell 0 1");
|
||||||
|
add(radioButton2ChartColor, "cell 1 1");
|
||||||
|
|
||||||
//---- radioButton3 ----
|
//---- radioButton3 ----
|
||||||
radioButton3.setText("radio 3");
|
radioButton3.setText("radio 3");
|
||||||
add(radioButton3, "cell 0 2");
|
add(radioButton3, "cell 0 2");
|
||||||
|
add(radioButton3ChartColor, "cell 1 2");
|
||||||
|
|
||||||
//---- checkBox1 ----
|
//---- checkBox1 ----
|
||||||
checkBox1.setText("switch");
|
checkBox1.setText("switch");
|
||||||
add(checkBox1, "cell 0 3");
|
add(checkBox1, "cell 0 3");
|
||||||
|
add(checkBox1ChartColor, "cell 1 3");
|
||||||
|
|
||||||
//---- checkBox2 ----
|
//---- checkBox2 ----
|
||||||
checkBox2.setText("minimal");
|
checkBox2.setText("minimal");
|
||||||
add(checkBox2, "cell 0 4");
|
add(checkBox2, "cell 0 4");
|
||||||
|
add(checkBox2ChartColor, "cell 1 4");
|
||||||
|
|
||||||
//---- durationLabel ----
|
//---- durationLabel ----
|
||||||
durationLabel.setText("Duration:");
|
durationLabel.setText("Duration:");
|
||||||
add(durationLabel, "cell 0 6 2 1");
|
add(durationLabel, "cell 0 6 3 1");
|
||||||
|
|
||||||
//---- durationField ----
|
//---- durationField ----
|
||||||
durationField.setModel(new SpinnerNumberModel(200, 100, null, 50));
|
durationField.setModel(new SpinnerNumberModel(200, 100, null, 50));
|
||||||
add(durationField, "cell 0 6 2 1");
|
add(durationField, "cell 0 6 3 1");
|
||||||
|
|
||||||
//---- buttonGroup1 ----
|
//---- buttonGroup1 ----
|
||||||
ButtonGroup buttonGroup1 = new ButtonGroup();
|
ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||||
@@ -116,10 +149,16 @@ public class FlatAnimatedIconTest
|
|||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
private JRadioButton radioButton1;
|
private JRadioButton radioButton1;
|
||||||
|
private FlatAnimatorTest.JChartColor radioButton1ChartColor;
|
||||||
|
private FlatAnimatorTest.LineChartPanel lineChartPanel;
|
||||||
private JRadioButton radioButton2;
|
private JRadioButton radioButton2;
|
||||||
|
private FlatAnimatorTest.JChartColor radioButton2ChartColor;
|
||||||
private JRadioButton radioButton3;
|
private JRadioButton radioButton3;
|
||||||
|
private FlatAnimatorTest.JChartColor radioButton3ChartColor;
|
||||||
private JCheckBox checkBox1;
|
private JCheckBox checkBox1;
|
||||||
|
private FlatAnimatorTest.JChartColor checkBox1ChartColor;
|
||||||
private JCheckBox checkBox2;
|
private JCheckBox checkBox2;
|
||||||
|
private FlatAnimatorTest.JChartColor checkBox2ChartColor;
|
||||||
private JLabel durationLabel;
|
private JLabel durationLabel;
|
||||||
private JSpinner durationField;
|
private JSpinner durationField;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
@@ -163,6 +202,11 @@ public class FlatAnimatedIconTest
|
|||||||
float xy = (SIZE - dotDiameter) / 2f;
|
float xy = (SIZE - dotDiameter) / 2f;
|
||||||
g.setColor( color );
|
g.setColor( color );
|
||||||
((Graphics2D)g).fill( new Ellipse2D.Float( xy, xy, dotDiameter, dotDiameter ) );
|
((Graphics2D)g).fill( new Ellipse2D.Float( xy, xy, dotDiameter, dotDiameter ) );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -200,6 +244,11 @@ public class FlatAnimatedIconTest
|
|||||||
int thumbY = y + 2;
|
int thumbY = y + 2;
|
||||||
g.setColor( Color.white );
|
g.setColor( Color.white );
|
||||||
((Graphics2D)g).fill( new Ellipse2D.Float( thumbX, thumbY, thumbSize, thumbSize ) );
|
((Graphics2D)g).fill( new Ellipse2D.Float( thumbX, thumbY, thumbSize, thumbSize ) );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -239,6 +288,11 @@ public class FlatAnimatedIconTest
|
|||||||
g.setColor( Color.red );
|
g.setColor( Color.red );
|
||||||
g.drawRect( x, y, w - 1, h - 1 );
|
g.drawRect( x, y, w - 1, h - 1 );
|
||||||
g.fillRect( x, y, Math.round( w * animatedValue ), h );
|
g.fillRect( x, y, Math.round( w * animatedValue ), h );
|
||||||
|
|
||||||
|
if( animatedValue != 0 && animatedValue != 1 ) {
|
||||||
|
Color chartColor = (Color) ((JComponent)c).getClientProperty( CHART_COLOR_KEY );
|
||||||
|
lineChartPanel.lineChart.addValue( animatedValue, chartColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"
|
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
root: new FormRoot {
|
root: new FormRoot {
|
||||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||||
"$columnConstraints": "[]para[fill]"
|
"$columnConstraints": "[][fill]para[grow,fill]"
|
||||||
"$rowConstraints": "[][][]para[][][grow][]"
|
"$rowConstraints": "[][][]para[][][grow][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
@@ -17,6 +17,16 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 0"
|
"value": "cell 0 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "radioButton1ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 0"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$LineChartPanel" ) {
|
||||||
|
name: "lineChartPanel"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 2 0 1 6"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
||||||
name: "radioButton2"
|
name: "radioButton2"
|
||||||
"text": "radio 2"
|
"text": "radio 2"
|
||||||
@@ -24,6 +34,11 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 1"
|
"value": "cell 0 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "radioButton2ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 1"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
||||||
name: "radioButton3"
|
name: "radioButton3"
|
||||||
"text": "radio 3"
|
"text": "radio 3"
|
||||||
@@ -31,23 +46,38 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 2"
|
"value": "cell 0 2"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "radioButton3ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 2"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "checkBox1"
|
name: "checkBox1"
|
||||||
"text": "switch"
|
"text": "switch"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 3"
|
"value": "cell 0 3"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "checkBox1ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 3"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "checkBox2"
|
name: "checkBox2"
|
||||||
"text": "minimal"
|
"text": "minimal"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 4"
|
"value": "cell 0 4"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatAnimatorTest$JChartColor" ) {
|
||||||
|
name: "checkBox2ChartColor"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 4"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "durationLabel"
|
name: "durationLabel"
|
||||||
"text": "Duration:"
|
"text": "Duration:"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 6 2 1"
|
"value": "cell 0 6 3 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JSpinner" ) {
|
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||||
name: "durationField"
|
name: "durationField"
|
||||||
@@ -57,11 +87,11 @@ new FormModel {
|
|||||||
value: 200
|
value: 200
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 6 2 1"
|
"value": "cell 0 6 3 1"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 415, 350 )
|
"size": new java.awt.Dimension( 810, 350 )
|
||||||
} )
|
} )
|
||||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||||
name: "buttonGroup1"
|
name: "buttonGroup1"
|
||||||
|
|||||||
@@ -170,8 +170,17 @@ public class FlatAnimatorTest
|
|||||||
LineChartPanel() {
|
LineChartPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
secondsWidthSlider.setValue( lineChart.getSecondsWidth() );
|
||||||
updateChartDelayedChanged();
|
updateChartDelayedChanged();
|
||||||
lineChart.setSecondWidth( 500 );
|
}
|
||||||
|
|
||||||
|
void setSecondsWidth( int secondsWidth ) {
|
||||||
|
lineChart.setSecondsWidth( secondsWidth );
|
||||||
|
secondsWidthSlider.setValue( secondsWidth );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void secondsWidthChanged() {
|
||||||
|
lineChart.setSecondsWidth( secondsWidthSlider.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateChartDelayedChanged() {
|
private void updateChartDelayedChanged() {
|
||||||
@@ -187,6 +196,7 @@ public class FlatAnimatorTest
|
|||||||
JScrollPane lineChartScrollPane = new JScrollPane();
|
JScrollPane lineChartScrollPane = new JScrollPane();
|
||||||
lineChart = new FlatAnimatorTest.LineChart();
|
lineChart = new FlatAnimatorTest.LineChart();
|
||||||
JLabel lineChartInfoLabel = new JLabel();
|
JLabel lineChartInfoLabel = new JLabel();
|
||||||
|
secondsWidthSlider = new JSlider();
|
||||||
updateChartDelayedCheckBox = new JCheckBox();
|
updateChartDelayedCheckBox = new JCheckBox();
|
||||||
JButton clearChartButton = new JButton();
|
JButton clearChartButton = new JButton();
|
||||||
|
|
||||||
@@ -211,6 +221,12 @@ public class FlatAnimatorTest
|
|||||||
lineChartInfoLabel.setText("X: time (500ms per line) / Y: value (10% per line)");
|
lineChartInfoLabel.setText("X: time (500ms per line) / Y: value (10% per line)");
|
||||||
add(lineChartInfoLabel, "cell 0 1 2 1");
|
add(lineChartInfoLabel, "cell 0 1 2 1");
|
||||||
|
|
||||||
|
//---- secondsWidthSlider ----
|
||||||
|
secondsWidthSlider.setMinimum(100);
|
||||||
|
secondsWidthSlider.setMaximum(2000);
|
||||||
|
secondsWidthSlider.addChangeListener(e -> secondsWidthChanged());
|
||||||
|
add(secondsWidthSlider, "cell 0 1 2 1");
|
||||||
|
|
||||||
//---- updateChartDelayedCheckBox ----
|
//---- updateChartDelayedCheckBox ----
|
||||||
updateChartDelayedCheckBox.setText("Update chart delayed");
|
updateChartDelayedCheckBox.setText("Update chart delayed");
|
||||||
updateChartDelayedCheckBox.setMnemonic('U');
|
updateChartDelayedCheckBox.setMnemonic('U');
|
||||||
@@ -227,6 +243,7 @@ public class FlatAnimatorTest
|
|||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
FlatAnimatorTest.LineChart lineChart;
|
FlatAnimatorTest.LineChart lineChart;
|
||||||
|
private JSlider secondsWidthSlider;
|
||||||
private JCheckBox updateChartDelayedCheckBox;
|
private JCheckBox updateChartDelayedCheckBox;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
}
|
}
|
||||||
@@ -238,18 +255,21 @@ public class FlatAnimatorTest
|
|||||||
implements Scrollable
|
implements Scrollable
|
||||||
{
|
{
|
||||||
private static final int NEW_SEQUENCE_TIME_LAG = 500;
|
private static final int NEW_SEQUENCE_TIME_LAG = 500;
|
||||||
private static final int NEW_SEQUENCE_GAP = 50;
|
private static final int NEW_SEQUENCE_GAP = 100;
|
||||||
|
|
||||||
private int secondWidth = 1000;
|
private boolean asynchron;
|
||||||
|
private int secondsWidth = 500;
|
||||||
|
|
||||||
private static class Data {
|
private static class Data {
|
||||||
final double value;
|
final double value;
|
||||||
final boolean dot;
|
final boolean dot;
|
||||||
|
final Color chartColor;
|
||||||
final long time; // in milliseconds
|
final long time; // in milliseconds
|
||||||
|
|
||||||
Data( double value, boolean dot, long time ) {
|
Data( double value, boolean dot, Color chartColor, long time ) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.dot = dot;
|
this.dot = dot;
|
||||||
|
this.chartColor = chartColor;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +280,8 @@ public class FlatAnimatorTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<Color, List<Data>> color2dataMap = new HashMap<>();
|
private final List<Data> syncChartData = new ArrayList<>();
|
||||||
|
private final Map<Color, List<Data>> asyncColor2dataMap = new HashMap<>();
|
||||||
private final Timer repaintTime;
|
private final Timer repaintTime;
|
||||||
private Color lastUsedChartColor;
|
private Color lastUsedChartColor;
|
||||||
private boolean updateDelayed;
|
private boolean updateDelayed;
|
||||||
@@ -270,13 +291,24 @@ public class FlatAnimatorTest
|
|||||||
repaintTime.setRepeats( false );
|
repaintTime.setRepeats( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableAsynchron() {
|
||||||
|
if( !syncChartData.isEmpty() )
|
||||||
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
asynchron = true;
|
||||||
|
}
|
||||||
|
|
||||||
void addValue( double value, Color chartColor ) {
|
void addValue( double value, Color chartColor ) {
|
||||||
addValue( value, false, chartColor );
|
addValue( value, false, chartColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
void addValue( double value, boolean dot, Color chartColor ) {
|
void addValue( double value, boolean dot, Color chartColor ) {
|
||||||
List<Data> chartData = color2dataMap.computeIfAbsent( chartColor, k -> new ArrayList<>() );
|
List<Data> chartData = asyncColor2dataMap.computeIfAbsent( chartColor, k -> new ArrayList<>() );
|
||||||
chartData.add( new Data( value, dot, System.nanoTime() / 1000000) );
|
Data data = new Data( value, dot, chartColor, System.nanoTime() / 1000000 );
|
||||||
|
if( asynchron )
|
||||||
|
chartData.add( data );
|
||||||
|
else
|
||||||
|
syncChartData.add( data );
|
||||||
|
|
||||||
lastUsedChartColor = chartColor;
|
lastUsedChartColor = chartColor;
|
||||||
|
|
||||||
@@ -288,7 +320,8 @@ public class FlatAnimatorTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
color2dataMap.clear();
|
syncChartData.clear();
|
||||||
|
asyncColor2dataMap.clear();
|
||||||
lastUsedChartColor = null;
|
lastUsedChartColor = null;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
@@ -299,8 +332,14 @@ public class FlatAnimatorTest
|
|||||||
this.updateDelayed = updateDelayed;
|
this.updateDelayed = updateDelayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSecondWidth( int secondWidth ) {
|
int getSecondsWidth() {
|
||||||
this.secondWidth = secondWidth;
|
return secondsWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSecondsWidth( int secondsWidth ) {
|
||||||
|
this.secondsWidth = secondsWidth;
|
||||||
|
repaint();
|
||||||
|
revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void repaintAndRevalidate() {
|
private void repaintAndRevalidate() {
|
||||||
@@ -311,7 +350,7 @@ public class FlatAnimatorTest
|
|||||||
if( lastUsedChartColor != null ) {
|
if( lastUsedChartColor != null ) {
|
||||||
// compute chart width of last used color and start of last sequence
|
// compute chart width of last used color and start of last sequence
|
||||||
int[] lastSeqX = new int[1];
|
int[] lastSeqX = new int[1];
|
||||||
int cw = chartWidth( color2dataMap.get( lastUsedChartColor ), lastSeqX );
|
int cw = chartWidth( asynchron ? asyncColor2dataMap.get( lastUsedChartColor ) : syncChartData, lastSeqX );
|
||||||
|
|
||||||
// scroll to end of last sequence (of last used color)
|
// scroll to end of last sequence (of last used color)
|
||||||
int lastSeqWidth = cw - lastSeqX[0];
|
int lastSeqWidth = cw - lastSeqX[0];
|
||||||
@@ -334,8 +373,7 @@ public class FlatAnimatorTest
|
|||||||
private void paintImpl( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) {
|
private void paintImpl( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) {
|
||||||
FlatUIUtils.setRenderingHints( g );
|
FlatUIUtils.setRenderingHints( g );
|
||||||
|
|
||||||
int secondWidth = (int) (this.secondWidth * scaleFactor);
|
int secondsWidth = (int) (this.secondsWidth * scaleFactor);
|
||||||
int seqGapWidth = (int) (NEW_SEQUENCE_GAP * scaleFactor);
|
|
||||||
|
|
||||||
Color lineColor = FlatUIUtils.getUIColor( "Component.borderColor", Color.lightGray );
|
Color lineColor = FlatUIUtils.getUIColor( "Component.borderColor", Color.lightGray );
|
||||||
Color lineColor2 = FlatLaf.isLafDark()
|
Color lineColor2 = FlatLaf.isLafDark()
|
||||||
@@ -356,25 +394,33 @@ public class FlatAnimatorTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// paint vertical lines
|
// paint vertical lines
|
||||||
int twoHundredMillisWidth = secondWidth / 5;
|
int twoHundredMillisWidth = secondsWidth / 5;
|
||||||
for( int i = twoHundredMillisWidth; i < width; i += twoHundredMillisWidth ) {
|
for( int i = twoHundredMillisWidth; i < width; i += twoHundredMillisWidth ) {
|
||||||
g.setColor( (i % secondWidth != 0) ? lineColor : lineColor2 );
|
g.setColor( (i % secondsWidth != 0) ? lineColor : lineColor2 );
|
||||||
g.drawLine( i, 0, i, height );
|
g.drawLine( i, 0, i, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint lines
|
// paint lines
|
||||||
for( Map.Entry<Color, List<Data>> e : color2dataMap.entrySet() ) {
|
for( Map.Entry<Color, List<Data>> e : asyncColor2dataMap.entrySet() ) {
|
||||||
List<Data> chartData = e.getValue();
|
List<Data> chartData = asynchron ? e.getValue() : syncChartData;
|
||||||
Color chartColor = e.getKey();
|
Color chartColor = e.getKey();
|
||||||
|
paintChartData( g, chartData, chartColor, height, scaleFactor );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paintChartData( Graphics2D g, List<Data> chartData, Color chartColor, int height, double scaleFactor ) {
|
||||||
if( FlatLaf.isLafDark() )
|
if( FlatLaf.isLafDark() )
|
||||||
chartColor = new HSLColor( chartColor ).adjustTone( 50 );
|
chartColor = new HSLColor( chartColor ).adjustTone( 50 );
|
||||||
Color temporaryValueColor = new Color( (chartColor.getRGB() & 0xffffff) | 0x40000000, true );
|
Color temporaryValueColor = new Color( (chartColor.getRGB() & 0xffffff) | 0x40000000, true );
|
||||||
|
|
||||||
|
int seqGapWidth = (int) (NEW_SEQUENCE_GAP * scaleFactor);
|
||||||
long seqTime = 0;
|
long seqTime = 0;
|
||||||
int seqX = 0;
|
int seqX = 0;
|
||||||
long ptime = 0;
|
long ptime = 0;
|
||||||
int px = 0;
|
int px = 0;
|
||||||
int py = 0;
|
int py = height - 1;
|
||||||
|
int cx = px;
|
||||||
|
int cy = py;
|
||||||
int pcount = 0;
|
int pcount = 0;
|
||||||
|
|
||||||
g.setColor( chartColor );
|
g.setColor( chartColor );
|
||||||
@@ -383,7 +429,8 @@ public class FlatAnimatorTest
|
|||||||
int size = chartData.size();
|
int size = chartData.size();
|
||||||
for( int i = 0; i < size; i++ ) {
|
for( int i = 0; i < size; i++ ) {
|
||||||
Data data = chartData.get( i );
|
Data data = chartData.get( i );
|
||||||
int dy = (int) ((height - 1) * data.value);
|
boolean useData = (data.chartColor == chartColor);
|
||||||
|
int dy = height - 1 - (int) ((height - 1) * data.value);
|
||||||
|
|
||||||
if( data.dot ) {
|
if( data.dot ) {
|
||||||
int dotx = px;
|
int dotx = px;
|
||||||
@@ -411,8 +458,9 @@ public class FlatAnimatorTest
|
|||||||
g.setColor( temporaryValueColor );
|
g.setColor( temporaryValueColor );
|
||||||
|
|
||||||
// line in sequence
|
// line in sequence
|
||||||
int dx = (int) (seqX + (((data.time - seqTime) / 1000.) * secondWidth));
|
int dx = (int) (seqX + (((data.time - seqTime) / 1000.) * secondsWidth));
|
||||||
g.drawLine( px, py, dx, dy );
|
if( useData )
|
||||||
|
g.drawLine( cx, cy, dx, dy );
|
||||||
px = dx;
|
px = dx;
|
||||||
pcount++;
|
pcount++;
|
||||||
|
|
||||||
@@ -422,6 +470,10 @@ public class FlatAnimatorTest
|
|||||||
|
|
||||||
py = dy;
|
py = dy;
|
||||||
ptime = data.time;
|
ptime = data.time;
|
||||||
|
|
||||||
|
if( useData ) {
|
||||||
|
cx = px;
|
||||||
|
cy = py;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,8 +502,11 @@ public class FlatAnimatorTest
|
|||||||
|
|
||||||
private int chartWidth() {
|
private int chartWidth() {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for( List<Data> chartData : color2dataMap.values() )
|
if( asynchron ) {
|
||||||
|
for( List<Data> chartData : asyncColor2dataMap.values() )
|
||||||
width = Math.max( width, chartWidth( chartData, null ) );
|
width = Math.max( width, chartWidth( chartData, null ) );
|
||||||
|
} else
|
||||||
|
width = Math.max( width, chartWidth( syncChartData, null ) );
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +527,7 @@ public class FlatAnimatorTest
|
|||||||
px = seqX;
|
px = seqX;
|
||||||
} else {
|
} else {
|
||||||
// line in sequence
|
// line in sequence
|
||||||
int dx = (int) (seqX + (((data.time - seqTime) / 1000.) * secondWidth));
|
int dx = (int) (seqX + (((data.time - seqTime) / 1000.) * secondsWidth));
|
||||||
px = dx;
|
px = dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +552,7 @@ public class FlatAnimatorTest
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) {
|
public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) {
|
||||||
return secondWidth;
|
return secondsWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -528,6 +583,11 @@ public class FlatAnimatorTest
|
|||||||
return new Dimension( UIScale.scale( 24 ), UIScale.scale( 12 ) );
|
return new Dimension( UIScale.scale( 24 ), UIScale.scale( 12 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getMinimumSize() {
|
||||||
|
return getPreferredSize();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent( Graphics g ) {
|
protected void paintComponent( Graphics g ) {
|
||||||
g.setColor( getForeground() );
|
g.setColor( getForeground() );
|
||||||
|
|||||||
@@ -143,6 +143,17 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 1 2 1"
|
"value": "cell 0 1 2 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||||
|
name: "secondsWidthSlider"
|
||||||
|
"minimum": 100
|
||||||
|
"maximum": 2000
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "secondsWidthChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 1 2 1"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "updateChartDelayedCheckBox"
|
name: "updateChartDelayedCheckBox"
|
||||||
"text": "Update chart delayed"
|
"text": "Update chart delayed"
|
||||||
|
|||||||
Reference in New Issue
Block a user