From 63f1835fd004995f16a7847ccc219fcabc92b65a Mon Sep 17 00:00:00 2001 From: edubecks Date: Mon, 19 Nov 2012 19:41:35 -0200 Subject: [PATCH] fixed problem related to hsv and rob colors. changed default values of text: color and alignment. other bugs related to legend persistence are fixed TODO: a field to edit table values, change colors of groups. --- .../legend/manager/LegendManagerUI.java | 31 ++- .../legend/api/AbstractLegendItemBuilder.java | 57 ++-- .../api/AbstractLegendItemRenderer.java | 26 +- .../gephi/legend/api/LegendController.java | 1 + LegendPlugin/build.xml | 16 +- LegendPlugin/nbproject/build-impl.xml | 90 +++---- LegendPlugin/nbproject/genfiles.properties | 16 +- LegendPlugin/nbproject/project.xml | 243 ++++++++++-------- .../builders/DescriptionItemBuilder.java | 5 +- .../plugin/builders/GroupsItemBuilder.java | 5 +- .../plugin/builders/ImageItemBuilder.java | 5 +- .../plugin/builders/TableItemBuilder.java | 92 +++++-- .../plugin/builders/TextItemBuilder.java | 9 +- .../gephi/legend/plugin/items/TableItem.java | 12 +- .../plugin/properties/TableProperty.java | 41 +-- .../plugin/renderers/GroupsItemRenderer.java | 6 + .../plugin/renderers/TableItemRenderer.java | 82 +++--- .../plugin/renderers/TextItemRenderer.java | 22 +- 18 files changed, 443 insertions(+), 316 deletions(-) diff --git a/DesktopLegend/src/org/gephi/desktop/legend/manager/LegendManagerUI.java b/DesktopLegend/src/org/gephi/desktop/legend/manager/LegendManagerUI.java index 6c5c75c35b..597fca36d7 100644 --- a/DesktopLegend/src/org/gephi/desktop/legend/manager/LegendManagerUI.java +++ b/DesktopLegend/src/org/gephi/desktop/legend/manager/LegendManagerUI.java @@ -239,7 +239,7 @@ public void refreshActiveLegendsComboBox() { } else { activeLegendsComboBox.setSelectedIndex(-1); } - refreshRenderers(); + refreshRenderers(activeLegendItem); refreshPropertySheet(); } @@ -310,12 +310,25 @@ private void removeLegendButtonActionPerformed(java.awt.event.ActionEvent evt) { }//GEN-LAST:event_removeLegendButtonActionPerformed private void activeLegendsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_activeLegendsComboBoxActionPerformed - Item activeLegendItem = (Item) activeLegendsComboBox.getSelectedItem(); - setActiveItem(activeLegendItem); + System.out.println("@Var: activeLegendsComboBox.getSelectedItem(): "+activeLegendsComboBox.getSelectedItem()); + if(activeLegendsComboBox.getSelectedItem()!=null){ + Item activeLegendItem = (Item) activeLegendsComboBox.getSelectedItem(); + Object currentRenderer = activeLegendItem.getData(LegendItem.RENDERER); + System.out.println("@Var: OLD currentRenderer: "+currentRenderer); + + setActiveItem(activeLegendItem); + refreshRenderers(activeLegendItem); + renderersComboBox.setSelectedItem(currentRenderer); + currentRenderer = activeLegendItem.getData(LegendItem.RENDERER); + System.out.println("@Var: NEW currentRenderer: "+currentRenderer); + } }//GEN-LAST:event_activeLegendsComboBoxActionPerformed public void selectActiveItemInCombobox(Item activeLegendItem) { +// setActiveItem(activeLegendItem); +// refreshRenderers(activeLegendItem); activeLegendsComboBox.setSelectedItem(activeLegendItem); + } public void setActiveItem(Item activeLegendItem) { @@ -327,9 +340,8 @@ public void setActiveItem(Item activeLegendItem) { // return; // } - Object currentRenderer = activeLegendItem.getData(LegendItem.RENDERER); - - renderersComboBox.setSelectedItem(currentRenderer); +// Object currentRenderer = activeLegendItem.getData(LegendItem.RENDERER); +// renderersComboBox.setSelectedItem(currentRenderer); Boolean hasDynamicProperties = activeLegendItem.getData(LegendItem.HAS_DYNAMIC_PROPERTIES); @@ -345,10 +357,10 @@ public void setActiveItem(Item activeLegendItem) { refreshPropertySheet(); } - private void refreshRenderers() { + private void refreshRenderers(Item activeLegendItem) { renderersComboBox.removeAllItems(); - Item activeLegendItem = (Item) activeLegendsComboBox.getSelectedItem(); +// Item activeLegendItem = (Item) activeLegendsComboBox.getSelectedItem(); if (activeLegendItem != null) { Collection renderers = Lookup.getDefault().lookupAll(LegendItemRenderer.class); @@ -360,8 +372,6 @@ private void refreshRenderers() { } } - Object currentRenderer = activeLegendItem.getData(LegendItem.RENDERER); - renderersComboBox.setSelectedItem(currentRenderer); } } @@ -399,6 +409,7 @@ private void legendItemBuildersComboBoxActionPerformed(java.awt.event.ActionEven tooltipRenderer.setTooltips(tooltips); }//GEN-LAST:event_legendItemBuildersComboBoxActionPerformed + private void renderersComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_renderersComboBoxActionPerformed Item item = (Item) activeLegendsComboBox.getSelectedItem(); Object renderer = renderersComboBox.getSelectedItem(); diff --git a/Legend API/src/org/gephi/legend/api/AbstractLegendItemBuilder.java b/Legend API/src/org/gephi/legend/api/AbstractLegendItemBuilder.java index e015e98070..72c77b1a19 100644 --- a/Legend API/src/org/gephi/legend/api/AbstractLegendItemBuilder.java +++ b/Legend API/src/org/gephi/legend/api/AbstractLegendItemBuilder.java @@ -8,6 +8,8 @@ import java.awt.Font; import java.io.File; import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; @@ -344,12 +346,10 @@ protected void writeXMLFromSingleProperty(XMLStreamWriter writer, PreviewPropert Object propertyValue = previewProperties.getValue(property.getName()); if (propertyValue != null) { - String text = PreviewProperties.getValueAsText(propertyValue); - if (text == null) { - text = writeValueAsText(propertyValue); - } + String text = writeValueAsText(propertyValue); writer.writeStartElement(XML_PROPERTY); String name = LegendModel.getPropertyFromPreviewProperty(property); + System.out.println("@Var: SAVING XML name: "+name+" , "+text); writer.writeAttribute(XML_NAME, name); writer.writeAttribute(XML_CLASS, propertyValue.getClass().getName()); writer.writeCharacters(text); @@ -418,10 +418,13 @@ public PreviewProperty readXMLToSingleLegendProperty(XMLStreamReader reader, Ite String valueString = reader.getElementText(); int propertyIndex = LegendProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValuesArrayList.get(propertyIndex).getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + +// Object value = PreviewProperties.readValueFromText(valueString, valueClass); +// if (value == null) { +// value = readValueFromText(valueString, valueClass); +// } + + Object value = readValueFromText(valueString, valueClass); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; @@ -435,7 +438,24 @@ public PreviewProperty readXMLToSingleLegendProperty(XMLStreamReader reader, Ite * @return */ protected Object readValueFromText(String valueString, Class valueClass) { - Object value = null; +// System.out.println("@Var: valueClass: "+valueClass); +// System.out.println("@Var: valueString: "+valueString); + + // bug + if(valueString.startsWith("org.netbeans.beaninfo.editors.ColorEditor")){ + // bug + Pattern rgb = Pattern.compile(".*\\[r=(\\d+),g=(\\d+),b=(\\d+)\\]"); + Matcher matcher = rgb.matcher(valueString); + if(matcher.matches()){ + valueString = "["+matcher.group(1) +","+matcher.group(2)+","+matcher.group(3)+"]"; + } + } + + Object value = PreviewProperties.readValueFromText(valueString, valueClass); + if (value != null){ + return value; + } + if (valueClass.equals(LegendItem.Alignment.class)) { value = availableAlignments[Integer.parseInt(valueString)]; } else if (valueClass.equals(LegendItem.Shape.class)) { @@ -448,8 +468,7 @@ protected Object readValueFromText(String valueString, Class valueClass) { value = Integer.parseInt(valueString); } else if (valueClass.equals(File.class)) { value = new File(valueString); - } - + } return value; } @@ -489,6 +508,9 @@ public ArrayList readXMLToLegendProperties(XMLStreamReader read switch (type) { case XMLStreamReader.START_ELEMENT: { PreviewProperty property = readXMLToSingleLegendProperty(reader, item); +// System.out.println("@Var: .. success property: "+property.getName()); +// System.out.println("@Var: property: "+property.getValue()); + properties.add(property); break; } @@ -508,7 +530,9 @@ public ArrayList readXMLToLegendProperties(XMLStreamReader read public void readXMLToRenderer(XMLStreamReader reader, Item item) throws XMLStreamException { if (reader.getLocalName().equals(XML_RENDERER)) { String valueString = reader.getElementText(); + System.out.println("@Var: renderer.... "+valueString); LegendItemRenderer availableRenderer = LegendController.getInstance().getRenderers().get(valueString); + System.out.println("@Var: renderer.... "+availableRenderer); if (availableRenderer != null) { item.setData(LegendItem.RENDERER, availableRenderer); } @@ -546,7 +570,6 @@ public Item readXMLToItem(XMLStreamReader reader, Integer newItemIndex) throws X // closing dynamic properties // data -// reader.nextTag(); reader.nextTag(); readXMLToData(reader, item); @@ -561,8 +584,8 @@ public Item readXMLToItem(XMLStreamReader reader, Integer newItemIndex) throws X // setting data item.setData(LegendItem.ITEM_INDEX, newItemIndex); - item.setData(LegendItem.PROPERTIES, legendPropertiesArray); item.setData(LegendItem.OWN_PROPERTIES, ownPropertiesArray); + item.setData(LegendItem.PROPERTIES, legendPropertiesArray); item.setData(LegendItem.HAS_DYNAMIC_PROPERTIES, hasDynamicProperties()); item.setData(LegendItem.DYNAMIC_PROPERTIES, dynamicPropertiesArray); @@ -580,7 +603,11 @@ public Item readXMLToItem(XMLStreamReader reader, Integer newItemIndex) throws X * @return */ protected String writeValueAsText(Object propertyValue) { - String text; + + String text = PreviewProperties.getValueAsText(propertyValue); + if (text != null) { + return text; + } if (propertyValue instanceof LegendItem.Alignment) { LegendItem.Alignment propertyValueString = (LegendItem.Alignment) propertyValue; text = propertyValueString.getValue(); @@ -641,7 +668,7 @@ public AbstractLegendItemBuilder() { updateDefaultValues(); } - public void updateDefaultValues() { + public final void updateDefaultValues() { this.defaultValuesArrayList = new ArrayList(); defaultValuesArrayList.add(this.defaultLabel); defaultValuesArrayList.add(this.defaultIsDisplaying); diff --git a/Legend API/src/org/gephi/legend/api/AbstractLegendItemRenderer.java b/Legend API/src/org/gephi/legend/api/AbstractLegendItemRenderer.java index c077993f7e..d43911d53c 100644 --- a/Legend API/src/org/gephi/legend/api/AbstractLegendItemRenderer.java +++ b/Legend API/src/org/gephi/legend/api/AbstractLegendItemRenderer.java @@ -55,9 +55,9 @@ public abstract class AbstractLegendItemRenderer implements LegendItemRenderer, * @param properties PreviewProperties of the current PreviewModel */ protected abstract void readOwnPropertiesAndValues(Item item, PreviewProperties properties); - + public abstract boolean isAnAvailableRenderer(Item item); - + private void readLocationProperties(Item item, PreviewProperties previewProperties) { if (item != null) { currentItemIndex = item.getData(LegendItem.ITEM_INDEX); @@ -171,7 +171,7 @@ private void renderProcessing(ProcessingTarget target) { // } else { // render(graphics2D, originTranslation, currentWidth, currentHeight); // } - + render(graphics2D, originTranslation, currentWidth, currentHeight); graphics2D.setTransform(saveState); } @@ -352,7 +352,7 @@ public PreviewProperty[] getProperties() { return new PreviewProperty[0]; } - private float legendDrawText(Graphics2D graphics2D, String text, Font font, Color color, double x, double y, Integer width, Integer height, Alignment alignment, boolean isComputingSpace) { + protected float legendDrawText(Graphics2D graphics2D, String text, Font font, Color color, double x, double y, Integer width, Integer height, Alignment alignment, boolean isComputingSpace) { if (text.isEmpty()) { return 0f; @@ -376,8 +376,15 @@ private float legendDrawText(Graphics2D graphics2D, String text, Font font, Colo float descent = 0, leading = 0; while (measurer.getPosition() < end) { TextLayout layout = measurer.nextLayout(width); + yText += layout.getAscent(); + + if (!isComputingSpace) { + + + + switch (alignment) { case LEFT: { break; @@ -400,6 +407,13 @@ private float legendDrawText(Graphics2D graphics2D, String text, Font font, Colo } } +// System.out.println("@Var: y: "+y); +// System.out.println("@Var: yText: " + (yText - y - layout.getAscent())); +// System.out.println("@Var: height: " + height); + if (yText - y -layout.getAscent() > height) { + break; + } +// break; layout.draw(graphics2D, xText, yText); } descent = layout.getDescent(); @@ -427,7 +441,9 @@ private float legendDrawText(Graphics2D graphics2D, String text, Font font, Colo * @return */ protected float legendDrawText(Graphics2D graphics2D, String text, Font font, Color color, double x, double y, Integer width, Integer height, Alignment alignment) { +// System.out.println("@Var: drawElementLabel: " + text); float spaceUsed = legendDrawText(graphics2D, text, font, color, x, y, width, height, alignment, true); +// System.out.println("@Var: spaceUsed: " + spaceUsed); y = y + (height - spaceUsed) / 2; return legendDrawText(graphics2D, text, font, color, x, y, width, height, alignment, false); } @@ -445,7 +461,7 @@ protected float legendDrawText(Graphics2D graphics2D, String text, Font font, Co protected float computeVerticalTextSpaceUsed(Graphics2D graphics2D, String text, Font font, Integer width) { return legendDrawText(graphics2D, text, font, Color.BLACK, 0, 0, width, currentHeight, Alignment.LEFT, true); } - + @Override public boolean isRendererForitem(Item item, PreviewProperties properties) { LegendItemRenderer renderer = item.getData(LegendItem.RENDERER); diff --git a/Legend API/src/org/gephi/legend/api/LegendController.java b/Legend API/src/org/gephi/legend/api/LegendController.java index 02fddede2b..77676943d8 100644 --- a/Legend API/src/org/gephi/legend/api/LegendController.java +++ b/Legend API/src/org/gephi/legend/api/LegendController.java @@ -83,6 +83,7 @@ private void registerLegendRenderers() { // registering renderers for (LegendItemRenderer legendItemRenderer : legendItemRenderers) { + System.out.println("@Var: registering ... legendItemRenderer: "+legendItemRenderer); renderers.put(legendItemRenderer.getClass().getName(), legendItemRenderer); } } diff --git a/LegendPlugin/build.xml b/LegendPlugin/build.xml index c765c0147a..351f65726b 100644 --- a/LegendPlugin/build.xml +++ b/LegendPlugin/build.xml @@ -1,8 +1,8 @@ - - - - - - Builds, tests, and runs the project org.gephi.legend.plugin. - - + + + + + + Builds, tests, and runs the project org.gephi.legend.plugin. + + diff --git a/LegendPlugin/nbproject/build-impl.xml b/LegendPlugin/nbproject/build-impl.xml index d49924d49e..9d013f1909 100644 --- a/LegendPlugin/nbproject/build-impl.xml +++ b/LegendPlugin/nbproject/build-impl.xml @@ -1,45 +1,45 @@ - - - - - - - - - - - - - You must set 'suite.dir' to point to your containing module suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LegendPlugin/nbproject/genfiles.properties b/LegendPlugin/nbproject/genfiles.properties index a843d2d306..f7d542517d 100644 --- a/LegendPlugin/nbproject/genfiles.properties +++ b/LegendPlugin/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=1a5ff41d -build.xml.script.CRC32=ab3151ec -build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=1a5ff41d -nbproject/build-impl.xml.script.CRC32=a26ba3c3 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 +build.xml.data.CRC32=cd54cd49 +build.xml.script.CRC32=ab3151ec +build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=cd54cd49 +nbproject/build-impl.xml.script.CRC32=a26ba3c3 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 diff --git a/LegendPlugin/nbproject/project.xml b/LegendPlugin/nbproject/project.xml index 0e67fa8a6f..d1435d4b64 100644 --- a/LegendPlugin/nbproject/project.xml +++ b/LegendPlugin/nbproject/project.xml @@ -1,107 +1,136 @@ - - - org.netbeans.modules.apisupport.project - - - org.gephi.legend.plugin - - - - org.gephi.data.attributes.api - - - - 0.8.0.7 - - - - org.gephi.graph.api - - - - 0.8.0.3 - - - - org.gephi.legend.api - - - - 1.0 - - - - org.gephi.lib.batik - - - - 1.7 - - - - org.gephi.lib.commons.codec - - - - 1.6 - - - - org.gephi.partition.api - - - - 0.8.0.1 - - - - org.gephi.preview.api - - - - 0.8.1.14 - - - - org.jfree - - - - 1.0 - - - - org.openide.util - - - - 8.19.1 - - - - org.openide.util.lookup - - - - 8.11.1 - - - - - org.gephi.legend.plugin.builders - org.gephi.legend.plugin.builders.description - org.gephi.legend.plugin.builders.description.elements - org.gephi.legend.plugin.builders.group - org.gephi.legend.plugin.builders.image - org.gephi.legend.plugin.builders.table - org.gephi.legend.plugin.builders.text - org.gephi.legend.plugin.custombuilders - org.gephi.legend.plugin.items - org.gephi.legend.plugin.properties - org.gephi.legend.plugin.propertyeditors - org.gephi.legend.plugin.renderers - org.gephi.legend.plugin.renderers.extra - - - - + + + org.netbeans.modules.apisupport.project + + + org.gephi.legend.plugin + + + + org.gephi.data.attributes.api + + + + 0.8.0.7 + + + + org.gephi.graph.api + + + + 0.8.0.3 + + + + org.gephi.legend.api + + + + 1.0 + + + + org.gephi.lib.batik + + + + 1.7 + + + + org.gephi.lib.commons.codec + + + + 1.6 + + + + org.gephi.partition.api + + + + 0.8.0.1 + + + + org.gephi.preview.api + + + + 0.8.1.14 + + + + org.jfree + + + + 1.0 + + + + org.openide.util + + + + 8.19.1 + + + + org.openide.util.lookup + + + + 8.11.1 + + + + + + unit + + org.gephi.desktop.welcome + + + + org.gephi.io.exporter.preview + + + + org.gephi.io.importer.plugin + + + + org.gephi.io.processor.plugin + + + + org.netbeans.libs.junit4 + + + + org.openide.io + + + + + + org.gephi.legend.plugin.builders + org.gephi.legend.plugin.builders.description + org.gephi.legend.plugin.builders.description.elements + org.gephi.legend.plugin.builders.group + org.gephi.legend.plugin.builders.image + org.gephi.legend.plugin.builders.table + org.gephi.legend.plugin.builders.text + org.gephi.legend.plugin.custombuilders + org.gephi.legend.plugin.items + org.gephi.legend.plugin.properties + org.gephi.legend.plugin.propertyeditors + org.gephi.legend.plugin.renderers + org.gephi.legend.plugin.renderers.extra + + + + diff --git a/LegendPlugin/src/org/gephi/legend/plugin/builders/DescriptionItemBuilder.java b/LegendPlugin/src/org/gephi/legend/plugin/builders/DescriptionItemBuilder.java index 15365ec3b3..62fbc14629 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/builders/DescriptionItemBuilder.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/builders/DescriptionItemBuilder.java @@ -359,10 +359,7 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i String valueString = reader.getElementText(); int propertyIndex = DescriptionProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValues[propertyIndex].getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + Object value = readValueFromText(valueString, valueClass); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; } diff --git a/LegendPlugin/src/org/gephi/legend/plugin/builders/GroupsItemBuilder.java b/LegendPlugin/src/org/gephi/legend/plugin/builders/GroupsItemBuilder.java index b8f1863721..00f39587f5 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/builders/GroupsItemBuilder.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/builders/GroupsItemBuilder.java @@ -418,10 +418,7 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i String valueString = reader.getElementText(); int propertyIndex = GroupsProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValues[propertyIndex].getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + Object value = readValueFromText(valueString, valueClass); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; } diff --git a/LegendPlugin/src/org/gephi/legend/plugin/builders/ImageItemBuilder.java b/LegendPlugin/src/org/gephi/legend/plugin/builders/ImageItemBuilder.java index 4ec438a895..af32c83f19 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/builders/ImageItemBuilder.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/builders/ImageItemBuilder.java @@ -179,10 +179,7 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i String valueString = reader.getElementText(); int propertyIndex = ImageProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValues[propertyIndex].getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + Object value = readValueFromText(valueString, valueClass); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; } diff --git a/LegendPlugin/src/org/gephi/legend/plugin/builders/TableItemBuilder.java b/LegendPlugin/src/org/gephi/legend/plugin/builders/TableItemBuilder.java index f34ac2240a..d646888dc4 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/builders/TableItemBuilder.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/builders/TableItemBuilder.java @@ -21,8 +21,8 @@ import org.gephi.legend.api.LegendModel; import org.gephi.legend.plugin.custombuilders.CustomTableItemBuilder; import org.gephi.legend.plugin.items.TableItem; -import org.gephi.legend.plugin.items.TableItem.HorizontalPosition; -import org.gephi.legend.plugin.items.TableItem.VerticalPosition; +import org.gephi.legend.plugin.items.TableItem.RowPosition; +import org.gephi.legend.plugin.items.TableItem.ColumnPosition; import org.gephi.legend.plugin.properties.TableProperty; import org.gephi.legend.plugin.renderers.TableItemRenderer; import org.gephi.legend.spi.CustomLegendItemBuilder; @@ -171,7 +171,7 @@ private PreviewProperty createLegendProperty(Item item, int property, Object val property); switch (property) { - case TableProperty.TABLE_VERTICAL_EXTRA_MARGIN: { + case TableProperty.TABLE_COLUMN_EXTRA_MARGIN: { previewProperty = PreviewProperty.createProperty( this, propertyString, @@ -182,7 +182,7 @@ private PreviewProperty createLegendProperty(Item item, int property, Object val break; } - case TableProperty.TABLE_HORIZONTAL_EXTRA_MARGIN: { + case TableProperty.TABLE_ROW_EXTRA_MARGIN: { previewProperty = PreviewProperty.createProperty( this, propertyString, @@ -226,7 +226,7 @@ private PreviewProperty createLegendProperty(Item item, int property, Object val break; } - case TableProperty.TABLE_HORIZONTAL_TEXT_ALIGNMENT: { + case TableProperty.TABLE_ROW_TEXT_ALIGNMENT: { previewProperty = PreviewProperty.createProperty( this, propertyString, @@ -237,18 +237,18 @@ private PreviewProperty createLegendProperty(Item item, int property, Object val break; } - case TableProperty.TABLE_HORIZONTAL_TEXT_POSITION: { + case TableProperty.TABLE_ROW_TEXT_POSITION: { previewProperty = PreviewProperty.createProperty( this, propertyString, - HorizontalPosition.class, + RowPosition.class, NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.horizontalText.position.displayName"), NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.horizontalText.position.description"), PreviewProperty.CATEGORY_LEGEND_PROPERTY).setValue(value); break; } - case TableProperty.TABLE_VERTICAL_TEXT_ALIGNMENT: { + case TableProperty.TABLE_COLUMN_TEXT_ALIGNMENT: { previewProperty = PreviewProperty.createProperty( this, propertyString, @@ -259,22 +259,22 @@ private PreviewProperty createLegendProperty(Item item, int property, Object val break; } - case TableProperty.TABLE_VERTICAL_TEXT_POSITION: { + case TableProperty.TABLE_COLUMN_TEXT_POSITION: { previewProperty = PreviewProperty.createProperty( this, propertyString, - VerticalPosition.class, + ColumnPosition.class, NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.verticalText.position.displayName"), NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.verticalText.position.description"), PreviewProperty.CATEGORY_LEGEND_PROPERTY).setValue(value); break; } - case TableProperty.TABLE_VERTICAL_TEXT_ROTATION: { + case TableProperty.TABLE_COLUMN_TEXT_ROTATION: { previewProperty = PreviewProperty.createProperty( this, propertyString, - TableItem.VerticalTextDirection.class, + TableItem.ColumnTextDirection.class, NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.verticalText.rotation.displayName"), NbBundle.getMessage(TableItemBuilder.class, "TableItem.property.verticalText.rotation.description"), PreviewProperty.CATEGORY_LEGEND_PROPERTY).setValue(value); @@ -613,8 +613,23 @@ public void writeXMLFromItemOwnProperties(XMLStreamWriter writer, Item item, Pre for (PreviewProperty property : ownProperties) { writeXMLFromSingleProperty(writer, property, previewProperties); } + } + @Override + protected String writeValueAsText(Object propertyValue) { + if( propertyValue instanceof RowPosition){ + return ((RowPosition)propertyValue).getValue(); + } + else if (propertyValue instanceof ColumnPosition){ + return ((ColumnPosition)propertyValue).getValue(); + } + else if (propertyValue instanceof TableItem.ColumnTextDirection){ + return ((TableItem.ColumnTextDirection)propertyValue).getValue(); + } + return super.writeValueAsText(propertyValue); } + + @Override public ArrayList readXMLToOwnProperties(XMLStreamReader reader, Item item) throws XMLStreamException { @@ -667,17 +682,30 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i String valueString = reader.getElementText(); int propertyIndex = TableProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValues[propertyIndex].getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + Object value = readValueFromText(valueString, valueClass); +// System.out.println("@Var: readXMLToSingleOwnProperty valueClass: "+valueClass); +// System.out.println("@Var: readXMLToSingleOwnProperty value: "+value); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; } + @Override + protected Object readValueFromText(String valueString, Class valueClass) { + if (valueClass.equals(TableItem.ColumnTextDirection.class)) { + return availableColumnTextDirection[Integer.parseInt(valueString)]; + } + else if (valueClass.equals(TableItem.RowPosition.class)) { + return availableRowPosition[Integer.parseInt(valueString)]; + } + else if (valueClass.equals(TableItem.ColumnPosition.class)) { + return availableColumnPosition[Integer.parseInt(valueString)]; + } + return super.readValueFromText(valueString, valueClass); + } + + + //default values - protected final Integer defaultColumnExtraMargin = 3; - protected final Integer defaultRowExtraMargin = 3; protected final Font defaultFont = new Font("Arial", Font.PLAIN, 13); protected final Color defaultFontColor = Color.BLACK; // grid @@ -687,25 +715,43 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i protected final Boolean defaultIsCellColoring = false; protected final Direction defaultCellColoringDirection = Direction.UP; // side labels - protected final HorizontalPosition defaultRowLabelsPosition = HorizontalPosition.LEFT; + protected final Integer defaultRowExtraMargin = 3; + protected final RowPosition defaultRowTextPosition = RowPosition.LEFT; protected final Alignment defaultRowTextAlignment = Alignment.JUSTIFIED; // up/bottom labels + protected final Integer defaultColumnExtraMargin = 3; protected final Alignment defaultColumnTextAlignment = Alignment.CENTER; - protected final VerticalPosition defaultColumnLabelsPosition = VerticalPosition.UP; - protected final TableItem.VerticalTextDirection defaultColumnTextRotation = TableItem.VerticalTextDirection.DIAGONAL; + protected final ColumnPosition defaultColumnTextPosition = ColumnPosition.UP; + protected final TableItem.ColumnTextDirection defaultColumnTextRotation = TableItem.ColumnTextDirection.DIAGONAL; private final Object[] defaultValues = { defaultFont, defaultFontColor, defaultIsCellColoring, // defaultCellColoringDirection, - defaultRowLabelsPosition, + defaultRowTextPosition, defaultRowTextAlignment, defaultRowExtraMargin, - defaultColumnLabelsPosition, + defaultColumnTextPosition, defaultColumnTextAlignment, defaultColumnTextRotation, defaultColumnExtraMargin, defaultIsDisplayingGrid, defaultGridColor }; + + private final Object[] availableColumnTextDirection = { + TableItem.ColumnTextDirection.VERTICAL, + TableItem.ColumnTextDirection.HORIZONTAL, + TableItem.ColumnTextDirection.DIAGONAL, + }; + + private final Object[] availableRowPosition = { + TableItem.RowPosition.RIGHT, + TableItem.RowPosition.LEFT + }; + + private final Object[] availableColumnPosition = { + TableItem.ColumnPosition.UP, + TableItem.ColumnPosition.BOTTOM + }; } \ No newline at end of file diff --git a/LegendPlugin/src/org/gephi/legend/plugin/builders/TextItemBuilder.java b/LegendPlugin/src/org/gephi/legend/plugin/builders/TextItemBuilder.java index 951469de22..4fa3aef5ff 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/builders/TextItemBuilder.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/builders/TextItemBuilder.java @@ -203,10 +203,7 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i String valueString = reader.getElementText(); int propertyIndex = TextProperty.getInstance().getProperty(propertyName); Class valueClass = defaultValues[propertyIndex].getClass(); - Object value = PreviewProperties.readValueFromText(valueString, valueClass); - if (value == null) { - value = readValueFromText(valueString, valueClass); - } + Object value = readValueFromText(valueString, valueClass); PreviewProperty property = createLegendProperty(item, propertyIndex, value); return property; } @@ -215,8 +212,8 @@ public PreviewProperty readXMLToSingleOwnProperty(XMLStreamReader reader, Item i // DEFAULT VALUES protected final String defaultBody = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras aliquam luctus ligula. Nunc mollis sagittis dui eget congue. Sed et turpis leo, vitae interdum magna. Pellentesque sollicitudin laoreet orci. Donec varius eleifend iaculis. Integer congue tempor nulla ac luctus. Nullam velit massa, convallis ut suscipit eget, auctor non velit. Etiam vitae velit sit amet justo luctus semper. Ut laoreet ullamcorper."; protected final Font defaultBodyFont = new Font("Arial", Font.PLAIN, 14); - protected final Color defaultBodyFontColor = Color.BLUE; - protected final Alignment defaultBodyFontAlignment = Alignment.JUSTIFIED; + protected final Color defaultBodyFontColor = Color.BLACK; + protected final Alignment defaultBodyFontAlignment = Alignment.LEFT; private final Object[] defaultValues = { defaultBody, defaultBodyFont, diff --git a/LegendPlugin/src/org/gephi/legend/plugin/items/TableItem.java b/LegendPlugin/src/org/gephi/legend/plugin/items/TableItem.java index 6605ec41f0..9d8527574f 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/items/TableItem.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/items/TableItem.java @@ -43,7 +43,7 @@ private LabelSelection(String value) { } - public enum VerticalPosition { + public enum ColumnPosition { UP(0), BOTTOM(1); @@ -53,7 +53,7 @@ public enum VerticalPosition { NbBundle.getMessage(TableItem.class, "TableItem.position.bottom") }; - private VerticalPosition(Integer value) { + private ColumnPosition(Integer value) { this.value = value; } @@ -68,7 +68,7 @@ public String getValue() { } - public enum HorizontalPosition { + public enum RowPosition { RIGHT(0), LEFT(1); @@ -78,7 +78,7 @@ public enum HorizontalPosition { NbBundle.getMessage(TableItem.class, "TableItem.position.left") }; - private HorizontalPosition(Integer value) { + private RowPosition(Integer value) { this.value = value; } @@ -93,7 +93,7 @@ public String getValue() { } - public enum VerticalTextDirection { + public enum ColumnTextDirection { // anti clockwise VERTICAL(0, -90d), @@ -107,7 +107,7 @@ public enum VerticalTextDirection { NbBundle.getMessage(TableItem.class, "TableItem.rotation.diagonal") }; - private VerticalTextDirection(Integer value, double rotationAngle) { + private ColumnTextDirection(Integer value, double rotationAngle) { this.rotationAngle = rotationAngle; this.value = value; } diff --git a/LegendPlugin/src/org/gephi/legend/plugin/properties/TableProperty.java b/LegendPlugin/src/org/gephi/legend/plugin/properties/TableProperty.java index 1539a6d83d..b6bb3a7c6e 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/properties/TableProperty.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/properties/TableProperty.java @@ -19,22 +19,22 @@ public class TableProperty { public static final int TABLE_FONT = 0; public static final int TABLE_FONT_COLOR = 1; public static final int TABLE_IS_CELL_COLORING = 2; - public static final int TABLE_CELL_COLORING_DIRECTION = 3; - public static final int TABLE_HORIZONTAL_TEXT_POSITION = 4; - public static final int TABLE_HORIZONTAL_TEXT_ALIGNMENT = 5; - public static final int TABLE_HORIZONTAL_EXTRA_MARGIN = 6; - public static final int TABLE_VERTICAL_TEXT_POSITION = 7; - public static final int TABLE_VERTICAL_TEXT_ALIGNMENT = 8; - public static final int TABLE_VERTICAL_TEXT_ROTATION = 9; - public static final int TABLE_VERTICAL_EXTRA_MARGIN = 10; - public static final int TABLE_IS_DISPLAYING_GRID = 11; - public static final int TABLE_GRID_COLOR = 12; - public static final int TABLE_LABEL = 13; +// public static final int TABLE_CELL_COLORING_DIRECTION = 3; + public static final int TABLE_ROW_TEXT_POSITION = 3; + public static final int TABLE_ROW_TEXT_ALIGNMENT = 4; + public static final int TABLE_ROW_EXTRA_MARGIN = 5; + public static final int TABLE_COLUMN_TEXT_POSITION = 6; + public static final int TABLE_COLUMN_TEXT_ALIGNMENT = 7; + public static final int TABLE_COLUMN_TEXT_ROTATION = 8; + public static final int TABLE_COLUMN_EXTRA_MARGIN = 9; + public static final int TABLE_IS_DISPLAYING_GRID = 10; + public static final int TABLE_GRID_COLOR = 11; + public static final int TABLE_LABEL = 12; public static String[] OWN_PROPERTIES = { ".table.font", ".table.font.color", ".table.isCellColoring", - ".table.cellColoringDirection", +// ".table.cellColoringDirection", ".table.horizontalText.position", ".table.horizontalText.alignment", ".table.horizontal.extraMargin", @@ -51,15 +51,16 @@ public class TableProperty { TABLE_FONT_COLOR, TABLE_IS_CELL_COLORING, // TABLE_CELL_COLORING_DIRECTION, - TABLE_HORIZONTAL_TEXT_POSITION, - TABLE_HORIZONTAL_TEXT_ALIGNMENT, - TABLE_HORIZONTAL_EXTRA_MARGIN, - TABLE_VERTICAL_TEXT_POSITION, - TABLE_VERTICAL_TEXT_ALIGNMENT, - TABLE_VERTICAL_TEXT_ROTATION, - TABLE_VERTICAL_EXTRA_MARGIN, + TABLE_ROW_TEXT_POSITION, + TABLE_ROW_TEXT_ALIGNMENT, + TABLE_ROW_EXTRA_MARGIN, + TABLE_COLUMN_TEXT_POSITION, + TABLE_COLUMN_TEXT_ALIGNMENT, + TABLE_COLUMN_TEXT_ROTATION, + TABLE_COLUMN_EXTRA_MARGIN, TABLE_IS_DISPLAYING_GRID, - TABLE_GRID_COLOR + TABLE_GRID_COLOR, + TABLE_LABEL }; public static String getLabelProperty(Integer itemIndex, int i) { diff --git a/LegendPlugin/src/org/gephi/legend/plugin/renderers/GroupsItemRenderer.java b/LegendPlugin/src/org/gephi/legend/plugin/renderers/GroupsItemRenderer.java index 1829fad45b..278ba2d590 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/renderers/GroupsItemRenderer.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/renderers/GroupsItemRenderer.java @@ -166,7 +166,13 @@ protected void drawElementLabel(Graphics2D graphics2D, int y, Integer width, Integer height) { + +// AffineTransform restore = graphics2D.getTransform(); +// AffineTransform arrange = new AffineTransform(graphics2D.getTransform()); +// arrange.translate(x, y); +// graphics2D.setTransform(arrange); legendDrawText(graphics2D, label, labelFont, labelColor, x, y, width, height, LegendItem.Alignment.CENTER); +// graphics2D.setTransform(restore); } /** diff --git a/LegendPlugin/src/org/gephi/legend/plugin/renderers/TableItemRenderer.java b/LegendPlugin/src/org/gephi/legend/plugin/renderers/TableItemRenderer.java index cb358a05ea..e902443ceb 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/renderers/TableItemRenderer.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/renderers/TableItemRenderer.java @@ -51,7 +51,7 @@ protected void createColumnLabels(Graphics2D graphics2D, AffineTransform arrange int cellSizeHeight = height / rowLabels.size(); // diagonal shift - Integer diagonalShift = (int) (cellSizeWidth * Math.cos(verticalTextDirection.rotationAngle())); + Integer diagonalShift = (int) (cellSizeWidth * Math.cos(columnTextDirection.rotationAngle())); //font @@ -74,11 +74,11 @@ protected void createColumnLabels(Graphics2D graphics2D, AffineTransform arrange } - switch (verticalTextDirection) { + switch (columnTextDirection) { case VERTICAL: { arrangeTranslation.translate(0, height - verticalExtraMargin); - arrangeTranslation.rotate(verticalTextDirection.rotationAngle()); + arrangeTranslation.rotate(columnTextDirection.rotationAngle()); graphics2D.setTransform(arrangeTranslation); @@ -95,15 +95,15 @@ protected void createColumnLabels(Graphics2D graphics2D, AffineTransform arrange case DIAGONAL: { //overriding centerdistance - centerDistance = (int) ((cellSizeWidth - fontHeight * Math.cos(verticalTextDirection.rotationAngle())) / 2); + centerDistance = (int) ((cellSizeWidth - fontHeight * Math.cos(columnTextDirection.rotationAngle())) / 2); //vertical shift for Diagonal case - int verticalShift = -(int) (height * Math.sin(verticalTextDirection.rotationAngle())); + int verticalShift = -(int) (height * Math.sin(columnTextDirection.rotationAngle())); // centering arrangeTranslation.translate(centerDistance - fontHeight / 2, 0); arrangeTranslation.translate(0, verticalShift + diagonalShift - verticalExtraMargin); - arrangeTranslation.rotate(verticalTextDirection.rotationAngle()); + arrangeTranslation.rotate(columnTextDirection.rotationAngle()); graphics2D.setTransform(arrangeTranslation); @@ -252,39 +252,37 @@ protected void renderToGraphics(Graphics2D graphics2D, AffineTransform origin, I graphics2D.setFont(font); FontMetrics fontMetrics = graphics2D.getFontMetrics(font); - int maxHorizontalTextWidth = Integer.MIN_VALUE; + int maxRowTextWidth = Integer.MIN_VALUE; for (StringBuilder label : rowLabels) { - maxHorizontalTextWidth = Math.max(maxHorizontalTextWidth, fontMetrics.stringWidth(label.toString())); + maxRowTextWidth = Math.max(maxRowTextWidth, fontMetrics.stringWidth(label.toString())); } int maxVerticalTextWidth = Integer.MIN_VALUE; for (StringBuilder label : columnLabels) { maxVerticalTextWidth = Math.max(maxVerticalTextWidth, fontMetrics.stringWidth(label.toString())); } - int horizontalLabelsWidth = maxHorizontalTextWidth + 2 * MINIMUM_MARGIN; + int rowLabelsWidth = maxRowTextWidth + 2 * MINIMUM_MARGIN; - int verticalLabelsHeight = 0; + int columnTextHeight = 0; int tableWidth = 0; int tableHeight = 0; - switch (verticalTextDirection) { + switch (columnTextDirection) { case VERTICAL: { - verticalLabelsHeight = maxVerticalTextWidth + 2 * MINIMUM_MARGIN; - tableHeight = height - verticalLabelsHeight; - tableWidth = width - horizontalLabelsWidth; - - + columnTextHeight = maxVerticalTextWidth + 2 * MINIMUM_MARGIN; + tableHeight = height - columnTextHeight; + tableWidth = width - rowLabelsWidth; break; } case DIAGONAL: { - verticalLabelsHeight = maxVerticalTextWidth + 2 * MINIMUM_MARGIN; - tableHeight = height - verticalLabelsHeight; - tableWidth = width - horizontalLabelsWidth - (int) Math.cos(verticalLabelsHeight); + columnTextHeight = maxVerticalTextWidth + 2 * MINIMUM_MARGIN; + tableHeight = height - columnTextHeight; + tableWidth = width - rowLabelsWidth - (int) Math.cos(columnTextHeight); break; } case HORIZONTAL: { - verticalLabelsHeight = fontMetrics.getHeight(); - tableHeight = height - verticalLabelsHeight; - tableWidth = width - horizontalLabelsWidth; + columnTextHeight = fontMetrics.getHeight(); + tableHeight = height - columnTextHeight; + tableWidth = width - rowLabelsWidth; break; } } @@ -300,29 +298,29 @@ protected void renderToGraphics(Graphics2D graphics2D, AffineTransform origin, I AffineTransform horizontalTextOrigin = new AffineTransform(origin); AffineTransform tableOrigin = new AffineTransform(origin); // arranging vertical text - if (verticalTextPosition == TableItem.VerticalPosition.UP) { + if (verticalTextPosition == TableItem.ColumnPosition.UP) { verticalTextOrigin.translate(0, 0); - tableOrigin.translate(0, verticalLabelsHeight); - horizontalTextOrigin.translate(0, verticalLabelsHeight); + tableOrigin.translate(0, columnTextHeight); + horizontalTextOrigin.translate(0, columnTextHeight); } - else if (verticalTextPosition == TableItem.VerticalPosition.BOTTOM) { + else if (verticalTextPosition == TableItem.ColumnPosition.BOTTOM) { verticalTextOrigin.translate(0, tableHeight); tableOrigin.translate(0, 0); horizontalTextOrigin.translate(0, 0); } // arranging horizontal text - if (horizontalTextPosition == TableItem.HorizontalPosition.LEFT) { + if (horizontalTextPosition == TableItem.RowPosition.LEFT) { horizontalTextOrigin.translate(0, 0); - verticalTextOrigin.translate(horizontalLabelsWidth, 0); - tableOrigin.translate(horizontalLabelsWidth, 0); + verticalTextOrigin.translate(rowLabelsWidth, 0); + tableOrigin.translate(rowLabelsWidth, 0); } - else if (horizontalTextPosition == TableItem.HorizontalPosition.RIGHT) { + else if (horizontalTextPosition == TableItem.RowPosition.RIGHT) { horizontalTextOrigin.translate(tableWidth + MINIMUM_MARGIN, 0); verticalTextOrigin.translate(0, 0); tableOrigin.translate(0, 0); } - createColumnLabels(graphics2D, verticalTextOrigin, verticalLabelsWidth, verticalLabelsHeight); - createRowLabels(graphics2D, horizontalTextOrigin, horizontalLabelsWidth, horizontalLabelsHeight); + createColumnLabels(graphics2D, verticalTextOrigin, verticalLabelsWidth, columnTextHeight); + createRowLabels(graphics2D, horizontalTextOrigin, rowLabelsWidth, horizontalLabelsHeight); if (isCellColoring) { normalizeWithMinValueZero(tableValuesFloat); } @@ -405,18 +403,18 @@ protected void readOwnPropertiesAndValues(Item item, PreviewProperties propertie font = properties.getFontValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_FONT)); fontColor = properties.getColorValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_FONT_COLOR)); isCellColoring = properties.getBooleanValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_IS_CELL_COLORING)); - verticalExtraMargin = properties.getIntValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_VERTICAL_EXTRA_MARGIN)); - horizontalExtraMargin = properties.getIntValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_HORIZONTAL_EXTRA_MARGIN)); + verticalExtraMargin = properties.getIntValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_COLUMN_EXTRA_MARGIN)); + horizontalExtraMargin = properties.getIntValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_ROW_EXTRA_MARGIN)); //grid gridColor = properties.getColorValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_GRID_COLOR)); isDisplayingGrid = properties.getBooleanValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_IS_DISPLAYING_GRID)); - horizontalTextAlignment = (Alignment) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_HORIZONTAL_TEXT_ALIGNMENT)); - verticalTextAlignment = (Alignment) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_VERTICAL_TEXT_ALIGNMENT)); - verticalTextPosition = (TableItem.VerticalPosition) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_VERTICAL_TEXT_POSITION)); - horizontalTextPosition = (TableItem.HorizontalPosition) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_HORIZONTAL_TEXT_POSITION)); - verticalTextDirection = (TableItem.VerticalTextDirection) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_VERTICAL_TEXT_ROTATION)); + horizontalTextAlignment = (Alignment) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_ROW_TEXT_ALIGNMENT)); + verticalTextAlignment = (Alignment) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_COLUMN_TEXT_ALIGNMENT)); + verticalTextPosition = (TableItem.ColumnPosition) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_COLUMN_TEXT_POSITION)); + horizontalTextPosition = (TableItem.RowPosition) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_ROW_TEXT_POSITION)); + columnTextDirection = (TableItem.ColumnTextDirection) properties.getValue(LegendModel.getProperty(TableProperty.OWN_PROPERTIES, itemIndex, TableProperty.TABLE_COLUMN_TEXT_ROTATION)); } protected Font font; @@ -428,11 +426,11 @@ protected void readOwnPropertiesAndValues(Item item, PreviewProperties propertie protected ArrayList columnLabelColors; protected ArrayList> valueColors; protected Boolean isCellColoring; - protected TableItem.HorizontalPosition horizontalTextPosition; + protected TableItem.RowPosition horizontalTextPosition; protected Alignment horizontalTextAlignment; - protected TableItem.VerticalPosition verticalTextPosition; + protected TableItem.ColumnPosition verticalTextPosition; protected Alignment verticalTextAlignment; - protected TableItem.VerticalTextDirection verticalTextDirection; + protected TableItem.ColumnTextDirection columnTextDirection; protected Integer verticalExtraMargin; protected Integer horizontalExtraMargin; private final Integer MINIMUM_MARGIN = 3; diff --git a/LegendPlugin/src/org/gephi/legend/plugin/renderers/TextItemRenderer.java b/LegendPlugin/src/org/gephi/legend/plugin/renderers/TextItemRenderer.java index ca36154f4c..eb1c2cb2df 100644 --- a/LegendPlugin/src/org/gephi/legend/plugin/renderers/TextItemRenderer.java +++ b/LegendPlugin/src/org/gephi/legend/plugin/renderers/TextItemRenderer.java @@ -59,14 +59,18 @@ protected void renderToGraphics(Graphics2D graphics2D, AffineTransform origin, I if (!body.isEmpty()) { graphics2D.setTransform(origin); - float currentSize = computeVerticalTextSpaceUsed(graphics2D, body, bodyFont, width); -// float currentSize = legendDrawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment, computeSpace); - while (currentSize > height) { - bodyFont = new Font(bodyFont.getName(), bodyFont.getStyle(), bodyFont.getSize() - 1); - currentSize = computeVerticalTextSpaceUsed(graphics2D, body, bodyFont, width); -// currentSize = legendDrawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment, computeSpace); - } - drawText(graphics2D, body, bodyFont, bodyFontColor, width, width, width, height, bodyAlignment); + // resizing text + +// float currentSize = computeVerticalTextSpaceUsed(graphics2D, body, bodyFont, width); +//// float currentSize = legendDrawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment, computeSpace); +// while (currentSize > height) { +// bodyFont = new Font(bodyFont.getName(), bodyFont.getStyle(), bodyFont.getSize() - 1); +// currentSize = computeVerticalTextSpaceUsed(graphics2D, body, bodyFont, width); +//// currentSize = legendDrawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment, computeSpace); +// } + + + drawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment); } } @@ -86,7 +90,7 @@ protected void renderToGraphics(Graphics2D graphics2D, AffineTransform origin, I * JUSTIFIED */ protected void drawText(Graphics2D graphics2D, String text, Font font, Color color, double x, double y, Integer width, Integer height, Alignment alignment) { - legendDrawText(graphics2D, body, bodyFont, bodyFontColor, 0, 0, width, height, bodyAlignment); + legendDrawText(graphics2D, text, font, color, x, y, width, height, alignment, false); } // OWN PROPERTIES