JFREE.ChartElement <T DIA.Element
L0.HasDescription "Element for displaying charts in diagrams"
>-- JFREE.ChartElement.component --> JFREE.Chart <R L0.IsWeaklyRelatedTo
-
\ No newline at end of file
+
+//#####################################################################
+// Filtering
+//#####################################################################
+JFREE.Filter <T L0.Library
+JFREE.Filter.used <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Boolean
+JFREE.Filter.fraction <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
\ No newline at end of file
public final Resource Dataset_seriesList;\r
public final Resource Dataset_seriesList_Inverse;\r
public final Resource DeviationRenderer;\r
+ public final Resource Filter;\r
+ public final Resource Filter_fraction;\r
+ public final Resource Filter_fraction_Inverse;\r
+ public final Resource Filter_used;\r
+ public final Resource Filter_used_Inverse;\r
public final Resource ImageTitle;\r
public final Resource Left;\r
public final Resource LegendTitle;\r
public static final String Dataset_seriesList = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList";\r
public static final String Dataset_seriesList_Inverse = "http://www.simantics.org/JFreeChart-1.0/Dataset/seriesList/Inverse";\r
public static final String DeviationRenderer = "http://www.simantics.org/JFreeChart-1.0/DeviationRenderer";\r
+ public static final String Filter = "http://www.simantics.org/JFreeChart-1.0/Filter";\r
+ public static final String Filter_fraction = "http://www.simantics.org/JFreeChart-1.0/Filter/fraction";\r
+ public static final String Filter_fraction_Inverse = "http://www.simantics.org/JFreeChart-1.0/Filter/fraction/Inverse";\r
+ public static final String Filter_used = "http://www.simantics.org/JFreeChart-1.0/Filter/used";\r
+ public static final String Filter_used_Inverse = "http://www.simantics.org/JFreeChart-1.0/Filter/used/Inverse";\r
public static final String ImageTitle = "http://www.simantics.org/JFreeChart-1.0/ImageTitle";\r
public static final String Left = "http://www.simantics.org/JFreeChart-1.0/Left";\r
public static final String LegendTitle = "http://www.simantics.org/JFreeChart-1.0/LegendTitle";\r
Dataset_seriesList = getResourceOrNull(graph, URIs.Dataset_seriesList);\r
Dataset_seriesList_Inverse = getResourceOrNull(graph, URIs.Dataset_seriesList_Inverse);\r
DeviationRenderer = getResourceOrNull(graph, URIs.DeviationRenderer);\r
+ Filter = getResourceOrNull(graph, URIs.Filter);\r
+ Filter_fraction = getResourceOrNull(graph, URIs.Filter_fraction);\r
+ Filter_fraction_Inverse = getResourceOrNull(graph, URIs.Filter_fraction_Inverse);\r
+ Filter_used = getResourceOrNull(graph, URIs.Filter_used);\r
+ Filter_used_Inverse = getResourceOrNull(graph, URIs.Filter_used_Inverse);\r
ImageTitle = getResourceOrNull(graph, URIs.ImageTitle);\r
Left = getResourceOrNull(graph, URIs.Left);\r
LegendTitle = getResourceOrNull(graph, URIs.LegendTitle);\r
import org.jfree.chart.plot.Plot;\r
import org.jfree.chart.plot.PlotOrientation;\r
import org.jfree.chart.renderer.category.CategoryItemRenderer;\r
+import org.jfree.data.general.Dataset;\r
import org.jfree.ui.RectangleInsets;\r
+import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.exception.DatabaseException;\r
for(int i = 0; i < properties.domains.size(); i++) {\r
cplot.setDomainAxis(i, (CategoryAxis)properties.domains.get(i).getAxis());\r
}\r
+ \r
+ \r
\r
IAxis axis;\r
for(int i = 0; i < properties.datasets.size(); i++) {\r
axis = properties.domainMappings.get(dataset);\r
if(axis != null && properties.ranges.contains(axis))\r
cplot.mapDatasetToDomainAxis(i, properties.domains.indexOf(axis));\r
+ \r
+ if (ds instanceof FilteredDataset) {\r
+ FilteredDataset f = (FilteredDataset)ds;\r
+ Boolean useFilter = (Boolean)properties.otherProperties.get("useFilter");\r
+ Double filterFraction = (Double)properties.otherProperties.get("filterFraction");\r
+ if (useFilter != null && filterFraction != null) {\r
+ f.setFiltering(useFilter);\r
+ f.setFilterFraction(filterFraction*0.01);\r
+ f.updateFiltered();\r
+ } else {\r
+ f.setFiltering(false);\r
+ }\r
+ }\r
}\r
\r
Boolean visibleGrid = (Boolean)properties.otherProperties.get("visibleGrid");\r
properties.otherProperties.put("visibleGrid", visibleGrid);\r
Boolean orientation = graph.getPossibleRelatedValue(resource, jfree.Plot_orientation);\r
properties.otherProperties.put("orientation", orientation);\r
+ \r
+ Boolean useFilter = graph.getPossibleRelatedValue(resource, JFreeChartResource.getInstance(graph).Filter_used, Bindings.BOOLEAN);\r
+ Double filterFraction = graph.getPossibleRelatedValue(resource, JFreeChartResource.getInstance(graph).Filter_fraction, Bindings.DOUBLE);\r
+ properties.otherProperties.put("useFilter", useFilter);\r
+ properties.otherProperties.put("filterFraction", filterFraction);\r
}\r
\r
}\r
--- /dev/null
+package org.simantics.jfreechart.chart;\r
+\r
+/**\r
+ * Interface for configuring data filtering.\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public interface FilteredDataset {\r
+\r
+ public boolean isFiltering();\r
+ public void setFiltering(boolean filtering);\r
+ \r
+ \r
+ public double getFilterFraction();\r
+ /**\r
+ * Sets filtering fraction 0 <= fraction <= 1\r
+ * With filtering fraction 0 nothing gets filtered.\r
+ * With filtering fraction 1 everything gets filtered.\r
+ * \r
+ * @param filterFraction\r
+ */\r
+ public void setFilterFraction(double filterFraction);\r
+ \r
+ public void updateFiltered();\r
+}\r
--- /dev/null
+package org.simantics.jfreechart.chart;\r
+\r
+/**\r
+ * Filters CategoryDataset by creating "Other" item for filtered data.\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+import java.util.List;\r
+\r
+import org.jfree.data.category.DefaultCategoryDataset;\r
+import org.jfree.data.general.AbstractDataset;\r
+import org.jfree.data.general.DatasetChangeEvent;\r
+\r
+@SuppressWarnings("rawtypes")\r
+public class FilteringCategoryDataset extends AbstractDataset implements org.jfree.data.category.CategoryDataset, FilteredDataset{\r
+ \r
+ private static final long serialVersionUID = -4955124650051030544L;\r
+ \r
+ org.jfree.data.category.CategoryDataset original;\r
+ DefaultCategoryDataset filtered;\r
+ org.jfree.data.category.CategoryDataset used;\r
+ \r
+ boolean filterRows = true;\r
+ boolean filtering = true;\r
+ double filterFraction = 0.05;\r
+ private Comparable other;\r
+ \r
+ public FilteringCategoryDataset(org.jfree.data.category.CategoryDataset dataset, Comparable other) {\r
+ this.original = dataset;\r
+ this.filtered = new DefaultCategoryDataset();\r
+ this.other = other;\r
+ this.used = filtered;\r
+ updateFiltered();\r
+ }\r
+ \r
+ @Override\r
+ public boolean isFiltering() {\r
+ return filtering;\r
+ }\r
+ \r
+ @Override\r
+ public void setFiltering(boolean filtering) {\r
+ this.filtering = filtering;\r
+ if (filtering)\r
+ used = filtered;\r
+ else\r
+ used = original;\r
+ notifyListeners(new DatasetChangeEvent(this, this));\r
+ }\r
+ \r
+ public void setFilterFraction(double filterFraction) {\r
+ this.filterFraction = filterFraction;\r
+ }\r
+ \r
+ public double getFilterFraction() {\r
+ return filterFraction;\r
+ }\r
+ \r
+ /**\r
+ * Filter rows or columns.\r
+ * @param filterRows\r
+ */\r
+ public void setFilterRows(boolean filterRows) {\r
+ this.filterRows = filterRows;\r
+ }\r
+ \r
+ public boolean isFilterRows() {\r
+ return filterRows;\r
+ }\r
+ \r
+ public void updateFiltered() {\r
+ filtered.clear();\r
+ if (filterRows) {\r
+ for (Object column : original.getColumnKeys()) {\r
+ Double total = 0.0;\r
+ Double other = 0.0;\r
+ for (Object row : original.getRowKeys()) {\r
+ Number value = original.getValue((Comparable) row, (Comparable)column);\r
+ if (value != null)\r
+ total+=value.doubleValue();\r
+ }\r
+ total *= filterFraction;\r
+ for (Object row : original.getRowKeys()) {\r
+ Number value = original.getValue((Comparable) row, (Comparable)column);\r
+ if (value == null)\r
+ continue;\r
+ if (value.doubleValue() > total) {\r
+ filtered.addValue(value, (Comparable) row, (Comparable)column);\r
+ } else {\r
+ other += value.doubleValue(); \r
+ }\r
+ }\r
+ if (other > 0.0) {\r
+ filtered.addValue(other, this.other, (Comparable)column);\r
+ }\r
+ }\r
+ } else {\r
+ for (Object row : original.getRowKeys()) {\r
+ Double total = 0.0;\r
+ Double other = 0.0;\r
+ for (Object column : original.getColumnKeys()) {\r
+ Number value = original.getValue((Comparable) row, (Comparable)column);\r
+ if (value != null)\r
+ total += value.doubleValue();\r
+ }\r
+ total *= filterFraction;\r
+ for (Object column : original.getColumnKeys()) {\r
+ Number value = original.getValue((Comparable) row, (Comparable)column);\r
+ if (value == null)\r
+ continue;\r
+ if (value.doubleValue() > total) {\r
+ filtered.addValue(value, (Comparable) row, (Comparable)column);\r
+ } else {\r
+ other += value.doubleValue(); \r
+ }\r
+ }\r
+ if (other > 0.0) {\r
+ filtered.addValue(other, (Comparable)row, this.other);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public int getColumnCount() {\r
+ return used.getColumnCount();\r
+ }\r
+ \r
+ @Override\r
+ public int getRowCount() {\r
+ return used.getRowCount();\r
+ }\r
+ \r
+ @Override\r
+ public Number getValue(Comparable rowKey, Comparable columnKey) {\r
+ return used.getValue(rowKey, columnKey);\r
+ }\r
+ \r
+ @Override\r
+ public Number getValue(int row, int column) {\r
+ return used.getValue(row, column);\r
+ }\r
+ \r
+ @Override\r
+ public List getColumnKeys() {\r
+ return used.getColumnKeys();\r
+ } \r
+ \r
+ @Override\r
+ public Comparable getColumnKey(int column) {\r
+ return used.getColumnKey(column);\r
+ }\r
+ \r
+ @Override\r
+ public List getRowKeys() {\r
+ return used.getRowKeys();\r
+ }\r
+ \r
+ @Override\r
+ public Comparable getRowKey(int row) {\r
+ return used.getRowKey(row);\r
+ }\r
+ \r
+ @Override\r
+ public int getRowIndex(Comparable key) {\r
+ return used.getRowIndex(key);\r
+ }\r
+ \r
+ @Override\r
+ public int getColumnIndex(Comparable key) {\r
+ return used.getColumnIndex(key);\r
+ }\r
+ \r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+package org.simantics.jfreechart.chart;\r
+\r
+import java.util.List;\r
+\r
+import org.jfree.data.general.AbstractDataset;\r
+import org.jfree.data.general.DatasetChangeEvent;\r
+import org.jfree.data.general.DefaultPieDataset;\r
+import org.jfree.data.general.PieDataset;\r
+\r
+/**\r
+ * Filters PieDataset by creating "Other" item for filtered data.\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+@SuppressWarnings("rawtypes")\r
+public class FilteringPieDataset extends AbstractDataset implements PieDataset, FilteredDataset{\r
+ \r
+ private static final long serialVersionUID = -4955124650051030544L;\r
+ \r
+ PieDataset original;\r
+ DefaultPieDataset filtered;\r
+ PieDataset used;\r
+ \r
+\r
+ boolean filtering = true;\r
+ double filterFraction = 0.05;\r
+ \r
+ private Comparable other = "other";\r
+ \r
+ public FilteringPieDataset(PieDataset dataset, Comparable other) {\r
+ this.original = dataset;\r
+ this.filtered = new DefaultPieDataset();\r
+ this.other = other;\r
+ this.used = filtered;\r
+ updateFiltered();\r
+ }\r
+ \r
+ @Override\r
+ public boolean isFiltering() {\r
+ return filtering;\r
+ }\r
+ \r
+ @Override\r
+ public void setFiltering(boolean filtering) {\r
+ this.filtering = filtering;\r
+ if (filtering)\r
+ used = filtered;\r
+ else\r
+ used = original;\r
+ notifyListeners(new DatasetChangeEvent(this, this));\r
+ }\r
+ \r
+\r
+ public void setFilterFraction(double filterFraction) {\r
+ this.filterFraction = filterFraction;\r
+ }\r
+ \r
+ public double getFilterFraction() {\r
+ return filterFraction;\r
+ }\r
+ \r
+ public void updateFiltered() {\r
+ filtered.clear();\r
+ Double total = 0.0;\r
+ Double other = 0.0;\r
+ for (Object key : original.getKeys()) {\r
+ total += original.getValue((Comparable) key).doubleValue();\r
+ }\r
+ total *= filterFraction;\r
+ for (Object key : original.getKeys()) {\r
+ Number value = original.getValue((Comparable) key).doubleValue();\r
+ \r
+ if (value.doubleValue() > total) {\r
+ filtered.setValue((Comparable) key,value);\r
+ } else {\r
+ other += value.doubleValue(); \r
+ }\r
+ }\r
+ if (other > 0.0) {\r
+ filtered.setValue(this.other, other);\r
+ }\r
+ \r
+ \r
+ }\r
+ \r
+ @Override\r
+ public List getKeys() {\r
+ return used.getKeys();\r
+ }\r
+ \r
+ @Override\r
+ public int getItemCount() {\r
+ return used.getItemCount();\r
+ }\r
+ \r
+ @Override\r
+ public Comparable getKey(int index) {\r
+ return used.getKey(index);\r
+ }\r
+ \r
+ @Override\r
+ public int getIndex(Comparable key) {\r
+ return used.getIndex(key);\r
+ }\r
+ \r
+ @Override\r
+ public Number getValue(Comparable key) {\r
+ return used.getValue(key);\r
+ }\r
+ \r
+ @Override\r
+ public Number getValue(int index) {\r
+ return used.getValue(index);\r
+ }\r
+\r
+}\r
protected void getOtherProperties(ReadGraph graph, PlotProperties properties) throws DatabaseException {\r
Boolean labelsVisible = graph.getPossibleRelatedValue(resource, JFreeChartResource.getInstance(graph).Plot_visibleLabels, Bindings.BOOLEAN);\r
properties.otherProperties.put("labelsVisible", labelsVisible);\r
+ \r
+ Boolean useFilter = graph.getPossibleRelatedValue(resource, JFreeChartResource.getInstance(graph).Filter_used, Bindings.BOOLEAN);\r
+ Double filterFraction = graph.getPossibleRelatedValue(resource, JFreeChartResource.getInstance(graph).Filter_fraction, Bindings.DOUBLE);\r
+ properties.otherProperties.put("useFilter", useFilter);\r
+ properties.otherProperties.put("filterFraction", filterFraction);\r
}\r
\r
@Override\r
pieDataset = (org.jfree.data.general.PieDataset)dataset;\r
piePlot.setDataset(pieDataset);\r
\r
+ if (pieDataset instanceof FilteredDataset) {\r
+ FilteredDataset f = (FilteredDataset)pieDataset;\r
+ Boolean useFilter = (Boolean)properties.otherProperties.get("useFilter");\r
+ Double filterFraction = (Double)properties.otherProperties.get("filterFraction");\r
+ if (useFilter != null && filterFraction != null) {\r
+ f.setFiltering(useFilter);\r
+ f.setFilterFraction(filterFraction*0.01);\r
+ f.updateFiltered();\r
+ } else {\r
+ f.setFiltering(false);\r
+ }\r
+ }\r
+ \r
Boolean labelsVisible = (Boolean)properties.otherProperties.get("labelsVisible");\r
if(Boolean.FALSE.equals(labelsVisible))\r
piePlot.setLabelGenerator(null);\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.jfreechart.chart.properties;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.utils.datastructures.Quad;\r
+\r
+/**\r
+ * PropertyFactory for finding a double property. Supports also finding the \r
+ * property from a first occurrence of resource ConsistsOf type HasProperty \r
+ * \r
+ * @author Teemu Lempinen\r
+ * @author Marko Luukkainen\r
+ *\r
+ */\r
+public class DoublePropertyFactory2 extends ReadFactoryImpl<Resource, String> {\r
+\r
+ final private String propertyURI;\r
+ final private String typeURI;\r
+ final private Double defaultValue;\r
+ \r
+ /**\r
+ * PropertyFactory for finding a boolean property with propertyURI\r
+ * \r
+ * @param propertyURI URI for the boolean property\r
+ */\r
+ public DoublePropertyFactory2(String propertyURI) {\r
+ this(null, propertyURI);\r
+ }\r
+ \r
+\r
+ /**\r
+ * PropertyFactory for finding a boolean property with propertyURI.\r
+ * \r
+ * Finds the property for first ObjectWithType(resource, L0.ConsistsOf, type)\r
+ * \r
+ * Supports inverting the result (e.g. if required information is IsHidden, but database contains IsVisible)\r
+ * \r
+ * @param typeURI URI for a resource (resource ConsistsOf type) (null allowed)\r
+ * @param propertyURI URI for the boolean property\r
+ * @param inverse Invert the result?\r
+ */\r
+ public DoublePropertyFactory2(String typeURI, String propertyURI) {\r
+ this(typeURI, propertyURI, 0.0);\r
+ }\r
+ \r
+ /**\r
+ * PropertyFactory for finding a boolean property with propertyURI.\r
+ * \r
+ * Finds the property for first ObjectWithType(resource, L0.ConsistsOf, type)\r
+ * \r
+ * Supports inverting the result (e.g. if required information is IsHidden, but database contains IsVisible)\r
+ * \r
+ * @param typeURI URI for a resource (resource ConsistsOf type) (null allowed -> not used)\r
+ * @param propertyURI URI for the boolean property\r
+ * @param inverse Invert the result?\r
+ * @param defaultValue default value\r
+ */\r
+ public DoublePropertyFactory2(String typeURI, String propertyURI, double defaultValue) {\r
+ this.propertyURI = propertyURI;\r
+ this.typeURI = typeURI;\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public Object getIdentity(Object inputContents) {\r
+ return new Quad<Resource, String, Object, Double>((Resource) inputContents, propertyURI, getClass(), defaultValue);\r
+ }\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph, Resource r) throws DatabaseException {\r
+ if(typeURI == null) {\r
+ // if no typeUri, use the default resource r\r
+ return getValue(graph, r);\r
+ } else {\r
+ // typeURI was defined, find the property for the first occurence of ConsistsOf type\r
+ Resource type = graph.getResource(typeURI);\r
+ for(Resource o : graph.syncRequest(new ObjectsWithType(r, Layer0.getInstance(graph).ConsistsOf, type))) {\r
+ // Returns the value for the first occurrence\r
+ return getValue(graph, o);\r
+ }\r
+ }\r
+ // if nothing was found with typeURI\r
+ return "";\r
+ }\r
+ \r
+ /**\r
+ * Return the value for a Boolean literal possibly inverted (or default if resource != Boolean literal) \r
+ * \r
+ * @param graph ReadGraph\r
+ * @param resource Literal Boolean resource \r
+ * @return value of the parameter (or default or inverted)\r
+ * @throws DatabaseException\r
+ */\r
+ private String getValue(ReadGraph graph, Resource resource) throws DatabaseException {\r
+ Double value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI), Bindings.DOUBLE);\r
+ if(value != null) {\r
+ return value.toString();\r
+ } else if (defaultValue != null){\r
+ return defaultValue.toString();\r
+ }\r
+ return "";\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+package org.simantics.jfreechart.chart.properties;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class DoublePropertyModifier2 extends TextModifyListenerImpl<Resource> {\r
+\r
+ final private String typeUri;\r
+ final private String propertyURI;\r
+\r
+ public DoublePropertyModifier2(ISessionContext context, String propertyURI) {\r
+ this.propertyURI = propertyURI;\r
+ this.typeUri = null;\r
+ }\r
+ \r
+ public DoublePropertyModifier2(ISessionContext context, String typeURI, String propertyURI) {\r
+ this.propertyURI = propertyURI;\r
+ this.typeUri = typeURI;\r
+ }\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text) throws DatabaseException {\r
+ if (typeUri == null)\r
+ applyValue(graph, input, text);\r
+ else {\r
+ Resource type = graph.getResource(typeUri);\r
+ for(Resource object : graph.syncRequest(new ObjectsWithType(input, Layer0.getInstance(graph).ConsistsOf, type))) {\r
+ applyValue(graph, object,text);\r
+ }\r
+ }\r
+ \r
+ }\r
+ \r
+ private void applyValue(WriteGraph graph, Resource input, String text) throws DatabaseException {\r
+ if (text == null || text.trim().isEmpty()) {\r
+ if (graph.hasStatement(input, graph.getResource(propertyURI)))\r
+ graph.denyValue(input, graph.getResource(propertyURI));\r
+ } else {\r
+ graph.claimLiteral(input, graph.getResource(propertyURI), Double.parseDouble(text), Bindings.DOUBLE);\r
+ }\r
+ }\r
+\r
+}\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
+import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2;\r
+import org.simantics.jfreechart.chart.properties.DoublePropertyModifier2;\r
import org.simantics.jfreechart.chart.properties.DoubleValidator;\r
import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
sc.setExpandVertical(true);\r
\r
composite = new Composite(sc, SWT.NONE);\r
- GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().numColumns(4).margins(3, 3).applyTo(composite);\r
\r
// General properties\r
Group general = new Group(composite, SWT.NONE);\r
sc.setContent(composite);\r
Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
sc.setMinSize(size);\r
+ \r
+ Group filteringGroup = new Group(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
+ hideGroup.setText("Filter");\r
+ label = new Label(filteringGroup, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Use:");\r
+ Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
+ useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
+ useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
+ label = new Label(filteringGroup, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Fraction:");\r
+ TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
+ fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
+ fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
+ fraction.setInputValidator(new DoubleValidator(true));\r
+ fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
}\r
\r
/**\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.jfreechart.chart.properties.BooleanPropertyFactory;\r
import org.simantics.jfreechart.chart.properties.BooleanSelectionListener;\r
+import org.simantics.jfreechart.chart.properties.DoublePropertyFactory2;\r
+import org.simantics.jfreechart.chart.properties.DoublePropertyModifier2;\r
import org.simantics.jfreechart.chart.properties.DoubleValidator;\r
import org.simantics.jfreechart.chart.properties.JFreeChartPropertyColorProvider;\r
import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
sc.setExpandVertical(true);\r
\r
composite = new Composite(sc, SWT.NONE);\r
- GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
\r
// General properties\r
Group general = new Group(composite, SWT.NONE);\r
hlabels.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels, true));\r
hlabels.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Plot_visibleLabels));\r
\r
+ \r
+ Group filteringGroup = new Group(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().applyTo(filteringGroup);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(filteringGroup);\r
+ hideGroup.setText("Filter");\r
+ label = new Label(filteringGroup, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Use:");\r
+ Button useFilter = new Button(filteringGroup, support, SWT.CHECK);\r
+ useFilter.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used, false));\r
+ useFilter.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_used));\r
+ label = new Label(filteringGroup, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).align(SWT.END, SWT.CENTER).applyTo(label);\r
+ label.setText("Fraction:");\r
+ TrackedText fraction = new TrackedText(filteringGroup, support, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fraction.getWidget());\r
+ fraction.setTextFactory(new DoublePropertyFactory2(JFreeChartResource.URIs.Plot,JFreeChartResource.URIs.Filter_fraction));\r
+ fraction.addModifyListener(new DoublePropertyModifier2(context, JFreeChartResource.URIs.Plot, JFreeChartResource.URIs.Filter_fraction));\r
+ fraction.setInputValidator(new DoubleValidator(true));\r
+ fraction.setColorProvider(new JFreeChartPropertyColorProvider(fraction.getResourceManager()));\r
+ \r
+ \r
sc.setContent(composite);\r
Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
sc.setMinSize(size);\r