Skip to content
Snippets Groups Projects
Commit 47b69263 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

added graphical shape preferences

parent 58949425
No related branches found
No related tags found
No related merge requests found
Showing with 405 additions and 48 deletions
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Fortiss Tooling Kernel Base User Interface
Bundle-SymbolicName: org.fortiss.tooling.base.ui
Bundle-SymbolicName: org.fortiss.tooling.base.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator
Require-Bundle: org.fortiss.tooling.base;bundle-version="1.0.0";visibility:=reexport,
......
source.. = src/
output.. = build/
bin.includes = META-INF/,\
.
.,\
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.fortiss.tooling.kernel.base.ui.preferences.MainPreferencePage"
id="org.fortiss.tooling.base.ui.preferences.main"
name="Fortiss Tooling">
</page>
<page
category="org.fortiss.tooling.base.ui.preferences.main"
class="org.fortiss.tooling.kernel.base.ui.preferences.GraphicalViewerPreferencePage"
id="org.fortiss.tooling.base.ui.preference.graphical.viewer"
name="Graphical Viewer">
</page>
</extension>
</plugin>
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.base.ui.editpart.figure;
import org.eclipse.jface.preference.IPreferenceStore;
import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator;
/**
* The visual style that {@link PrettyInsetEllipse} and
* {@link PrettyRoundedRectangle} use for representation.
*
* @author schwitzer
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public enum EVisualStyle {
/** Traditional (since 2007) CCTS style with soft gradients. */
Traditional,
/** Glossy (since 2010) CCTS style with glossy reflective gradients. */
Glossy;
/** Constant used as key for the preference-store of this plug-in. */
public static final String ID = "figures.visualStyle";
/** Cached preference-store to lookup visual style. */
private static IPreferenceStore preferenceStore = ToolingBaseUIActivator
.getDefault().getPreferenceStore();
/**
* Returns the visual style from the preference store of this plug-in's
* {@link ToolingBaseUIActivator}.
*/
public static EVisualStyle get() {
final String name = preferenceStore.getString(ID);
if (name == null || name.length() == 0) {
return Traditional; // Default.
}
return valueOf(name);
}
/**
* Sets the visual style in the preference store of this plug-in's
* {@link ToolingBaseUIActivator}.
*/
public static void set(EVisualStyle style) {
preferenceStore.setValue(ID, style.name());
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.base.ui.editpart.figure;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Path;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* This shape consists of an ellipse that is surrounded by transparent insets.
* It is filled with {@link #getBackgroundColor()}. A light top-down gradient
* from white to the background color is painted over the background color to
* achieve a 3 dimensional reflection effect.
* <p>
* Anti-aliasing is enabled.
*
* @author hummel
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class PrettyInsetEllipse extends Shape {
/** The transparent insets surrounding this shape. */
protected final Insets insets;
/** A complete set of reflections for 3 dimensional ellipses. */
protected static final Image reflections = AbstractUIPlugin
.imageDescriptorFromPlugin("edu.tum.cs.ccts.editor.base",
"icons/ellipse-reflections.png").createImage();
/**
* Creates a new ConQAT-Shape with given {@link Insets}.
*
* @param insets
* the transparent insets surrounding this shape.
*/
public PrettyInsetEllipse(Insets insets) {
this.insets = insets;
}
/**
* {@inheritDoc}
* <p>
* Paints a rounded rectangle with a top-down gradient from white to
* background color.
*/
@Override
protected void fillShape(Graphics gfx) {
EVisualStyle style = EVisualStyle.get();
gfx.pushState();
Rectangle croppedBounds = getCroppedBounds();
if (style == EVisualStyle.Glossy) {
// Glossy style.
gfx.setBackgroundColor(ColorConstants.black);
gfx.setAntialias(SWT.ON);
gfx.setAlpha(48);
gfx.fillOval(croppedBounds.getCopy().translate(5, 5));
gfx.restoreState();
if (getBackgroundColor().getGreen() < 255) {
gfx.setBackgroundColor(ColorConstants.red);
} else {
gfx.setBackgroundColor(ColorConstants.orange);
}
gfx.fillOval(croppedBounds);
gfx.setForegroundColor(ColorConstants.yellow);
gfx.setAlpha(180);
Path path = new Path(null);
path.addArc(croppedBounds.x, croppedBounds.y, croppedBounds.width,
croppedBounds.height, 0, 360);
gfx.setClip(path);
gfx.fillGradient(croppedBounds, true);
gfx.restoreState();
path.dispose();
gfx.setAntialias(SWT.ON);
gfx.setAlpha(220);
gfx.drawImage(reflections, new Rectangle(reflections.getBounds()),
croppedBounds);
} else {
// Traditional style is default.
gfx.fillOval(croppedBounds);
gfx.setForegroundColor(ColorConstants.white);
gfx.setAlpha(200);
Path path = new Path(null);
path.addArc(croppedBounds.x, croppedBounds.y, croppedBounds.width,
croppedBounds.height, 0, 360);
gfx.setClip(path);
gfx.fillGradient(croppedBounds, true);
}
gfx.popState();
}
/** Returns a copy of the bounds cropped by the insets. */
protected Rectangle getCroppedBounds() {
return bounds.getCropped(insets);
}
/**
* {@inheritDoc}
* <p>
* Additionally enables anti-aliasing.
*/
@Override
protected void outlineShape(Graphics gfx) {
EVisualStyle style = EVisualStyle.get();
gfx.pushState();
gfx.setAntialias(SWT.ON);
if (style == EVisualStyle.Glossy) {
// Glossy style.
gfx.setLineCap(SWT.CAP_ROUND);
final int scale = (int) gfx.getAbsoluteScale();
gfx.setLineWidth(scale + 1);
Color bg = ColorConstants.orange;
Color bgdark = new Color(bg.getDevice(), Math.max(0,
(bg.getRed() - 20)), Math.max(0, (bg.getGreen() - 20)),
Math.max(0, (bg.getBlue() - 20)));
gfx.setForegroundColor(bgdark);
gfx.drawOval(getCroppedBounds());
bgdark.dispose();
} else {
// Traditional style is default.
gfx.drawOval(getCroppedBounds().resize(-1, -1));
}
gfx.popState();
}
}
......@@ -23,6 +23,7 @@ import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator;
......@@ -39,7 +40,6 @@ import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator;
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
// TODO (FH): add glossy effect: see commented code below
public class PrettyRoundedRectangle extends Shape {
/** The radius to use for the rounded corners of this shape. */
......@@ -66,33 +66,34 @@ public class PrettyRoundedRectangle extends Shape {
/** {@inheritDoc} */
@Override
protected void fillShape(Graphics gfx) {
// final EVisualStyle style = EVisualStyle.get();
EVisualStyle style = EVisualStyle.get();
gfx.pushState();
// if (style == EVisualStyle.Glossy) {
// // Glossy style.
// final Rectangle b = getCroppedBounds();
// gfx.setBackgroundColor(ColorConstants.black);
// gfx.setAlpha(48);
// gfx.fillRoundRectangle(b.getCopy().translate(5, 5), cornerRadius,
// cornerRadius);
// gfx.restoreState();
// gfx.fillRoundRectangle(b, cornerRadius, cornerRadius);
// gfx.setAlpha(255);
// gfx.drawImage(linearBlend, new Rectangle(linearBlend.getBounds()),
// b.getCopy().resize(-1, -b.height / 2 - 1));
// gfx.setAlpha(200);
// gfx.drawImage(
// radialBlend,
// new Rectangle(radialBlend.getBounds()),
// b.getCopy().resize(-1, -b.height / 2 - 1)
// .translate(0, b.height / 2));
// } else {
// Traditional style is default.
gfx.fillRoundRectangle(getCroppedBounds(), cornerRadius, cornerRadius);
gfx.setForegroundColor(ColorConstants.white);
gfx.setAlpha(200);
gfx.fillGradient(getCroppedBounds().resize(0, -cornerRadius), true);
// }
if (style == EVisualStyle.Glossy) {
// Glossy style.
final Rectangle b = getCroppedBounds();
gfx.setBackgroundColor(ColorConstants.black);
gfx.setAlpha(48);
gfx.fillRoundRectangle(b.getCopy().translate(5, 5), cornerRadius,
cornerRadius);
gfx.restoreState();
gfx.fillRoundRectangle(b, cornerRadius, cornerRadius);
gfx.setAlpha(255);
gfx.drawImage(linearBlend, new Rectangle(linearBlend.getBounds()),
b.getCopy().resize(-1, -b.height / 2 - 1));
gfx.setAlpha(200);
gfx.drawImage(
radialBlend,
new Rectangle(radialBlend.getBounds()),
b.getCopy().resize(-1, -b.height / 2 - 1)
.translate(0, b.height / 2));
} else {
// Traditional style is default.
gfx.fillRoundRectangle(getCroppedBounds(), cornerRadius,
cornerRadius);
gfx.setForegroundColor(ColorConstants.white);
gfx.setAlpha(200);
gfx.fillGradient(getCroppedBounds().resize(0, -cornerRadius), true);
}
gfx.popState();
}
......@@ -108,27 +109,27 @@ public class PrettyRoundedRectangle extends Shape {
*/
@Override
protected void outlineShape(Graphics gfx) {
// final EVisualStyle style = EVisualStyle.get();
final EVisualStyle style = EVisualStyle.get();
gfx.pushState();
gfx.setAntialias(SWT.ON);
// if (style == EVisualStyle.Glossy) {
// // Glossy style.
// gfx.setLineCap(SWT.CAP_ROUND);
// final int scale = (int) gfx.getAbsoluteScale();
// gfx.setLineWidth(scale + 1);
// final Color bg = gfx.getBackgroundColor();
// final Color bgdark = new Color(bg.getDevice(), max(0,
// (bg.getRed() - 80)), max(0, (bg.getGreen() - 80)), max(0,
// (bg.getBlue() - 80)));
// gfx.setForegroundColor(bgdark);
// gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1),
// cornerRadius, cornerRadius);
// bgdark.dispose();
// } else {
// Traditional style is default.
gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1), cornerRadius,
cornerRadius);
// }
if (style == EVisualStyle.Glossy) {
// Glossy style.
gfx.setLineCap(SWT.CAP_ROUND);
int scale = (int) gfx.getAbsoluteScale();
gfx.setLineWidth(scale + 1);
Color bg = gfx.getBackgroundColor();
Color bgdark = new Color(bg.getDevice(), Math.max(0,
(bg.getRed() - 80)), Math.max(0, (bg.getGreen() - 80)),
Math.max(0, (bg.getBlue() - 80)));
gfx.setForegroundColor(bgdark);
gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1),
cornerRadius, cornerRadius);
bgdark.dispose();
} else {
// Traditional style is default.
gfx.drawRoundRectangle(getCroppedBounds().resize(-1, -1),
cornerRadius, cornerRadius);
}
gfx.popState();
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.base.ui.preferences;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.kernel.base.ui.editpart.figure.EVisualStyle;
/**
* Main preference page for graphical viewer editors.
*
* @author schwitzer
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class GraphicalViewerPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
/** Constructor. */
public GraphicalViewerPreferencePage() {
super(GRID);
setPreferenceStore(ToolingBaseUIActivator.getDefault()
.getPreferenceStore());
setDescription("Graphical Editor Preferences");
}
/** {@inheritDoc} */
@Override
protected void createFieldEditors() {
addField(new RadioGroupFieldEditor(EVisualStyle.ID,
"Presentation of Graphical Shapes", 1, new String[][] {
{ "Traditional", EVisualStyle.Traditional.name() },
{ "Glossy", EVisualStyle.Glossy.name() } },
getFieldEditorParent()));
}
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench) {
// nothing to do
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.base.ui.preferences;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.fortiss.tooling.kernel.base.ui.ToolingBaseUIActivator;
/**
* Main preference page for Fortiss Tooling. This does not provide preferences
* itself, but serves as parent for other preference pages.
*
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class MainPreferencePage extends FieldEditorPreferencePage implements
IWorkbenchPreferencePage {
/** Constructor. */
public MainPreferencePage() {
super(GRID);
setPreferenceStore(ToolingBaseUIActivator.getDefault()
.getPreferenceStore());
setDescription("Preferences for Fortiss Tooling");
}
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench) {
// nothing to do
}
/** {@inheritDoc} */
@Override
protected void createFieldEditors() {
// nothing to do
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment