Error editing my custom World series

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
europa
Newbie
Newbie
Posts: 1
Joined: Fri Aug 22, 2014 12:00 am

Error editing my custom World series

Post by europa » Tue Sep 02, 2014 10:13 am

Hello,
following the example WorldDemo, I tried to create a map from a shp file.

I Extended World class:

Code: Select all

public class MyWorld extends World {

  @Override
  public void loadMapFromResource(Map Series, String ShpName) throws FileNotFoundException, IOException, ClassNotFoundException, Exception {
    MYSHP myshp = new MYSHP();
    myshp.loadMap(Series, ShpName, false);
  }
} 
Then in my MyPHP class I load the *.shp map file. The map is created correctly, but

1. In the editing dialog of the graphic I get an exception from the cellrenderer of the series because of the missing image icon.
I resolved it overwriting the method getBitmapEditor()

Code: Select all

@Override
public java.net.URL getBitmapEditor() {
  return MyWorld.class.getResource("World.gif");
} 

is this the correct way to handle the image icon to show ?

2.When I try to edit the series I get another exception:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
    at com.steema.teechart.editors.SeriesGeneral.AddSeriesEditor(SeriesGeneral.java:243)
    at com.steema.teechart.editors.SeriesGeneral.<init>(SeriesGeneral.java:137)
    at com.steema.teechart.editors.ChartEditorPanel.jTree1_valueChanged(ChartEditorPanel.java:314)
    at com.steema.teechart.editors.ChartEditor_jTree1_treeSelectionAdapter.valueChanged(ChartEditorPanel.java:393)
    at javax.swing.JTree.fireValueChanged(JTree.java:2919)
    at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3378)
    at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:634)
    at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1092)
    at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:293)
    at javax.swing.tree.DefaultTreeSelectionModel.addSelectionPaths(DefaultTreeSelectionModel.java:333)
    at javax.swing.tree.DefaultTreeSelectionModel.addSelectionPath(DefaultTreeSelectionModel.java:309)
    at javax.swing.JTree.addSelectionPath(JTree.java:1738)
    at com.steema.teechart.editors.ChartEditorPanel$1.mouseClicked(ChartEditorPanel.java:331)
    at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    at java.awt.Component.processMouseEvent(Component.java:6508)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
    at java.awt.Dialog.show(Dialog.java:1082)
    at java.awt.Component.show(Component.java:1651)
    at java.awt.Component.setVisible(Component.java:1603)
    at java.awt.Window.setVisible(Window.java:1014)
    at java.awt.Dialog.setVisible(Dialog.java:1005)
    at com.steema.teechart.editors.ChartEditor.editChart(ChartEditor.java:107)
    at com.steema.teechart.editors.ChartEditor.editChart(ChartEditor.java:102)
    at com.steema.teechart.Commander$1.actionPerformed(Commander.java:116)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 
I found out that the SeriesGeneral.AddSeriesEditor method loads the correct editor of the series calling:

Code: Select all

int n = com.steema.teechart.misc.Utils.seriesTypesIndex(series.getClass());
Class editorClass = com.steema.teechart.editors.Utils.seriesEditorsOf[n]; 

but the classes handled are:

Code: Select all

final static public Class[] seriesEditorsOf = {
        com.steema.teechart.editors.series.LineEditor.class,
        com.steema.teechart.editors.series.PointsEditor.class,
        com.steema.teechart.editors.series.AreaEditor.class,
        com.steema.teechart.editors.series.FastLineEditor.class,
        com.steema.teechart.editors.series.LineEditor.class,
        com.steema.teechart.editors.series.BarEditor.class,
        com.steema.teechart.editors.series.BarEditor.class,
        com.steema.teechart.editors.series.PieEditor.class,
        com.steema.teechart.editors.series.ShapeEditor.class,
        com.steema.teechart.editors.series.ArrowEditor.class,
        com.steema.teechart.editors.series.PointsEditor.class, //Bubble
        com.steema.teechart.editors.series.GanttEditor.class,
        com.steema.teechart.editors.series.CandleEditor.class,
        com.steema.teechart.editors.series.DonutEditor.class,
        com.steema.teechart.editors.series.VolumeEditor.class,
        com.steema.teechart.editors.series.BarEditor.class, //Bar3D
        com.steema.teechart.editors.series.Point3DEditor.class, //Points3D
        com.steema.teechart.editors.series.PolarEditor.class,
        com.steema.teechart.editors.series.PolarEditor.class, //Radar
        com.steema.teechart.editors.series.ClockEditor.class,
        com.steema.teechart.editors.series.PolarEditor.class, //WindRose
        com.steema.teechart.editors.series.PyramidEditor.class,
        com.steema.teechart.editors.series.SurfaceEditor.class,
        com.steema.teechart.editors.series.PointsEditor.class, //LinePoint
        com.steema.teechart.editors.series.BarEditor.class, //BarJoin
        com.steema.teechart.editors.series.ColorGridEditor.class,
        com.steema.teechart.editors.series.WaterFallEditor.class,
        com.steema.teechart.editors.series.HistoEditor.class,
        com.steema.teechart.editors.series.ErrBarEditor.class, //Errorcom.steema.teechart.misc
        com.steema.teechart.editors.series.ErrBarEditor.class,
        com.steema.teechart.editors.series.ContourEditor.class,
        com.steema.teechart.editors.series.SmithEditor.class,
        com.steema.teechart.editors.series.CalendarEditor.class,
        com.steema.teechart.editors.series.HighLowEditor.class,
        com.steema.teechart.editors.series.TriSurfaceEditor.class,
        com.steema.teechart.editors.series.FunnelEditor.class,
        com.steema.teechart.editors.series.BoxPlotEditor.class,
        com.steema.teechart.editors.series.BoxPlotEditor.class, //HorizBox
        com.steema.teechart.editors.series.AreaEditor.class,
        com.steema.teechart.editors.series.TowerEditor.class,
com.steema.teechart.editors.series.PointFigureEditor.class,
        com.steema.teechart.editors.series.GaugesEditor.class,
        com.steema.teechart.editors.series.Vector3DEditor.class,
        com.steema.teechart.editors.series.MapEditor.class,
        com.steema.teechart.editors.series.BezierEditor.class,
        com.steema.teechart.editors.series.ImageEditor.class,
        com.steema.teechart.editors.series.IsoSurfaceEditor.class,
com.steema.teechart.editors.series.CircularGaugeEditor.class,
com.steema.teechart.editors.series.LinearGaugeEditor.class,
com.steema.teechart.editors.series.LinearGaugeEditor.class, //VerticalLinearGauge
com.steema.teechart.editors.series.LinearGaugeEditor.class, //Missing NumericGauge
        com.steema.teechart.editors.series.KnobGaugeEditor.class,
        com.steema.teechart.editors.series.HistoEditor.class, //HorizHistogram
        com.steema.teechart.editors.series.MapEditor.class, //World
        com.steema.teechart.editors.series.ErrorPointEditor.class,
com.steema.teechart.editors.series.ErrorPoint3DEditor.class
    }; 
How could I add the link between MyWorld and MyEditor extends com.steema.teechart.editors.series.MapEditor ?

Please find attached the test project. Only the first map works in order to limit the size of the attachment.

Thankyou
Attachments
TeeChartMap.zip
(389.24 KiB) Downloaded 1167 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Error editing my custom World series

Post by Yeray » Wed Sep 03, 2014 10:49 am

Hello,

First of all note the Editor is designed to be used for the developers, to help them to make their charts writing as much code as possible for them, not to be accessed by the end user.

A few tips to keep in mind if you own the sources and you want to create a new series, as you are actually doing, and you want it to be modifiable through the editor:

- The first thing you'll have to do is to move your new series class to the TeeChart sources, so it can be found when rebuilding the TeeChart sources. So I've moved MyWorld.java to com.steema.teechart.styles, MYSHP.java to com.steema.teechart.misc and Italia.shp and Italia.shx to com.steema.teechart.styles.maps.

- At MYSHP.java, set the correct route for Italia.shp and Italia.shx. This is, at loadMap() method changing the following lines:

Code: Select all

		InputStream ff = this.getClass().getResourceAsStream(manifest + FileName + ".shp");

Code: Select all

			InputStream ffx = this.getClass().getResourceAsStream(manifest + FileName + ".shx");
- At MyWorld.java, set the correct route for World.gif:

Code: Select all

	@Override
	public java.net.URL getBitmapEditor() {
		return MyWorld.class.getResource("icons/World.gif");
	}
- Increment SERIESTYPESCOUNT at misc/Utils.java:

Code: Select all

    public static final int SERIESTYPESCOUNT = 57;
- At editors/Utils.java, add an editor at the end of seriesEditorsOf:

Code: Select all

    final static public Class[] seriesEditorsOf = {
        // ...
        com.steema.teechart.editors.series.MapEditor.class
    };
Doing these changes your example works fine for me here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply