📄 swtaxiseditor.java
字号:
"Paint")); // Use a colored text field to show the color final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor); GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); canvasGridData.heightHint = 20; colorCanvas.setLayoutData(canvasGridData); Button selectColorButton = new Button(general, SWT.PUSH); selectColorButton.setText(localizationResources.getString("Select...")); selectColorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the color-change dialog ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Title_Color")); dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB()); RGB rgb = dlg.open(); if (rgb != null) { // create the new color and set it to the // SwtPaintCanvas SWTAxisEditor.this.labelPaintColor = new Color( getDisplay(), rgb); colorCanvas.setColor( SWTAxisEditor.this.labelPaintColor); } } } ); Group other = new Group(this, SWT.NONE); FillLayout tabLayout = new FillLayout(); tabLayout.marginHeight = tabLayout.marginWidth = 4; other.setLayout(tabLayout); other.setText(localizationResources.getString("Other")); this.otherTabs = new TabFolder(other, SWT.NONE); TabItem item1 = new TabItem(this.otherTabs, SWT.NONE); item1.setText(" " + localizationResources.getString("Ticks") + " "); Composite ticks = new Composite(this.otherTabs, SWT.NONE); ticks.setLayout(new GridLayout(3, false)); this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK); this.showTickLabelsCheckBox.setText(localizationResources.getString( "Show_tick_labels")); this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible()); this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); new Label(ticks, SWT.NONE).setText(localizationResources.getString( "Tick_label_font")); this.tickLabelFontField = new Text(ticks, SWT.BORDER); this.tickLabelFontField.setText(this.tickLabelFont.toString()); //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), // axis.getTickLabelFont())); this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH); selectTickLabelFontButton.setText(localizationResources.getString( "Select...")); selectTickLabelFontButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the font-change dialog FontDialog dlg = new FontDialog(getShell()); dlg.setText( localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont}); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTAxisEditor.this.font != null) { SWTAxisEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTAxisEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //tickLabelFontField.setFont(font); SWTAxisEditor.this.tickLabelFontField.setText( SWTAxisEditor.this.font.getFontData()[0] .toString()); SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0]; } } } ); this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK); this.showTickMarksCheckBox.setText(localizationResources.getString( "Show_tick_marks")); this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible()); this.showTickMarksCheckBox.setLayoutData(new GridData( SWT.FILL, SWT.CENTER, true, false, 3, 1)); item1.setControl(ticks); } /** * A static method that returns a panel that is appropriate * for the axis type. * * @param parent the parent. * @param style the style. * @param axis the axis whose properties are to be displayed/edited * in the composite. * @return A composite or <code>null</code< if axis is <code>null</code>. */ public static SWTAxisEditor getInstance(Composite parent, int style, Axis axis) { if (axis != null) { // return the appropriate axis editor if (axis instanceof NumberAxis) return new SWTNumberAxisEditor(parent, style, (NumberAxis) axis ); else return new SWTAxisEditor(parent, style, axis); } else return null; } /** * Returns a reference to the tabbed composite. * * @return A reference to the tabbed composite. */ public TabFolder getOtherTabs() { return this.otherTabs; } /** * Returns the current axis label. * * @return The current axis label. */ public String getLabel() { return this.label.getText(); } /** * Returns the current label font. * * @return The current label font. */ public java.awt.Font getLabelFont() { return SWTUtils.toAwtFont(getDisplay(), this.labelFont, true); } /** * Returns the current label paint. * * @return The current label paint. */ public Paint getTickLabelPaint() { return SWTUtils.toAwtColor(this.tickLabelPaintColor); } /** * Returns the current label font. * * @return The current label font. */ public java.awt.Font getTickLabelFont() { return SWTUtils.toAwtFont(getDisplay(), this.tickLabelFont, true); } /** * Returns the current label paint. * * @return The current label paint. */ public Paint getLabelPaint() { return SWTUtils.toAwtColor(this.labelPaintColor); } /** * Sets the properties of the specified axis to match * the properties defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { axis.setLabel(getLabel()); axis.setLabelFont(getLabelFont()); axis.setLabelPaint(getLabelPaint()); axis.setTickMarksVisible(this.showTickMarksCheckBox.getSelection()); axis.setTickLabelsVisible(this.showTickLabelsCheckBox.getSelection()); axis.setTickLabelFont(getTickLabelFont()); axis.setTickLabelPaint(getTickLabelPaint()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -