Axis values display issue

41 views
Skip to first unread message

Caglar K

unread,
Jun 14, 2016, 10:51:11 AM6/14/16
to metsci-...@googlegroups.com

  Hi,


  I've attached a part of my application displaying a StackedTimePlot2D graphic. Here, the Y axis values are displaying within the graphic area. Is there any way to make them display at left part of the axis line, similar to the time values which are displaying below time axis line ?


 This is how i create the plot as usual; frequencyPlot = plot.createTimePlot("FREQUENCY");





Additionaly, I attempt to make vertical lines visible by;


frequencyPlot.getGridPainter().setShowVerticalLines(true);


In some cases, vertical lines display at same point where the time ticks exist, but in some cases they just don't; as displayed in screenshot.  Is there any way to fix this situation ?


Thanks.



Caglar K

unread,
Jun 21, 2016, 4:58:32 AM6/21/16
to Glimpse

Situation below is critical for me. 

Is there any way to resolve this issue ?

Thanks.

14 Haziran 2016 Salı 17:51:11 UTC+3 tarihinde Caglar K yazdı:

Mike Hogye

unread,
Jun 21, 2016, 8:39:55 AM6/21/16
to metsci-...@googlegroups.com
Here's how to show y-axis ticks in an exterior axis instead of the interior axis ("row" is a TimePlotInfo, so change it to "frequencyPlot" for your case):

        // Remove tick-painter for interior axis
        row.getLayout( ).removePainter( row.getAxisPainter( ) );
        
        // Remove mouse-listener for interior axis
        // XXX: Still working on this

        // Create tick-painter for exterior axis
        NumericYAxisPainter yAxisPainter = new NumericYAxisPainter( row.getAxisPainter( ).getLabelHandlerY( ) );

        // Create mouse-listener for exterior axis
        GlimpseMouseAllListener yAxisListener = new AxisMouseListener1D( );

        GlimpseAxisLayout1D yAxisLayout = new GlimpseAxisLayoutY( );
        yAxisLayout.addGlimpseMouseAllListener( yAxisListener );
        yAxisLayout.addPainter( yAxisPainter );
        row.getLabelLayout( ).addLayout( yAxisLayout );


--
You received this message because you are subscribed to the Google Groups "Glimpse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to .
For more options, visit https://groups.google.com/d/optout.

Brandon Borkholder

unread,
Jun 21, 2016, 8:52:41 AM6/21/16
to metsci-...@googlegroups.com
The quickest way to do this is to remove the existing NumericXYAxisPainter and then add a new NumericYAxisPainter with the associated layouts and mouse listeners.

The steps are roughly below and you'll want to look more into how Plot2D creates its Y axis, mouse listener, label handler and layout.

frequencyPlot is now a TimePlotInfoImpl object with a field called axisPainter.  In StackedTimePlot2D.createTimePlot0(PlotInfo), the NumericXYAxisPainter is added to the layout.  Call frequencyPlot.getLayout().removePainter(frequencyPlot.getAxisPainter()) to remove the painter.  You should not use frequencyPlot.getAxisPainter() is any way now.

Next, get the underlying layout via frequencyPlot.getBaseLayout() and add a new GlimpseAxisLayout1D in a manner similar to Plot2D.initializePainters().  Use the existing layouts from frequencyPlot where possible (e.g. frequencyPlot.plotLayout for the plot area).

I hope this helps, it's a good bit of code to write and play with to get the functionality you want.

Mike Hogye

unread,
Jun 21, 2016, 8:56:52 AM6/21/16
to metsci-...@googlegroups.com
Still looking at the grid alignment. I thought I knew what the issue was, but now I'm not so sure. CollapsibleTimelinePlotExample has the same problem ...

Mike Hogye

unread,
Jun 21, 2016, 9:26:54 AM6/21/16
to Glimpse
I should mention: for the exterior-axis code above to work, you have to turn on plot labels:

        timePlot.setShowLabels( true );

The exterior axis needs a place in the layout to draw itself, and we're (ab)using the part of the layout usually used for the plot label -- so plot labels need to be enabled. This is not how the layout was intended to be used, but it works fine.

The clean, non-hacky way to do it is what Brandon describes.

Mike Hogye

unread,
Jun 21, 2016, 9:43:11 AM6/21/16
to Glimpse
Okay, the grid alignment problem has to do with timezones. Here's the fix:

        row.getGridPainter( ).setTickHandlerX( row.getStackedTimePlot( ).getDefaultTimeline( ).getAxisPainter( ).getLabelHandler( ) );


I was originally trying to use

        row.getStackedTimePlot( ).getTimeAxisLabelHandler( )

... but we are setting the axis timezone with:

        timePlot.getDefaultTimeline( ).setTimeZone( ... );

... which sets the timezone for the default TimelineInfo's tick-handler, but does not affect the tick-handler in timePlot itself.

I think this is the intended behavior -- timePlot could have more than one TimelineInfo (e.g. one timezone along the top and another along the bottom). But I wonder if we could make it less confusing somehow.

Geoffrey Ulman

unread,
Jun 21, 2016, 9:51:58 AM6/21/16
to Glimpse
I believe there's also simply a bug in com.metsci.glimpse.plot.timeline.layout.TimelineInfo

Newly created rows don't use the default timePlot.getTimeAxisLabelHandler( ) (instead they create their own). Looks like it's just a one line fix.

Geoffrey Ulman

unread,
Jun 21, 2016, 10:19:12 AM6/21/16
to Glimpse

Another alternative if you need complete customization of the content of a timeline row is to use StackedPlot2D.createPlot( ) instead of createTimePlot( ) or createEventPlot( ).

This will just create a blank space in the timeline and provide you a GlimpseLayout via PlotInfo.getBaseLayout( ) to which you can add any arbitrary layouts and painters.

So it's significantly more code to set up, but you can achieve any arrangement of components that you're after.

           
            CollapsibleTimePlot2D plot = new CollapsibleTimePlot2D( );
       
           
// the label size is used to offset the time axis at the bottom of the plot
           
// we need this value to line up with the width of the yAxisLayout we set below
           
int labelSize = 50;
            plot
.setShowLabels( true );
            plot
.setLabelSize( labelSize );
       
            plot
.setPlotSpacing( 10 );


           
// create a blank custom row in the timeline
           
// (just a GlimpseLayout with no event listeners or painters)
           
PlotInfo plot1 = plot.createPlot( "custom-plot-id-" + i, new Axis1D( ) );
           
           
// set plot to consume all available space
            plot1
.setSize( -1 );
           
           
// create a layout area to display the y axis

           
GlimpseAxisLayout1D yAxisLayout = new GlimpseAxisLayoutY( );

           
           
// create a painter to draw the y axis and add it to the yAxisLayout
           
GridAxisLabelHandler axisLabels = new GridAxisLabelHandler( );
            axisLabels
.setTickSpacing( 30 );
           
NumericYAxisPainter yAxisPainter = new NumericYAxisPainter( axisLabels );
            yAxisLayout
.addPainter( yAxisPainter );
           
           
// create a plotting area for the data
           
GlimpseAxisLayout2D plotLayout = new GlimpseAxisLayout2D( );
           
           
// pass events to the underlying layout (which has listeners allowing the timeline
           
// bounds to be adjusted)
            plotLayout
.setEventConsumer( false );
            plot1
.getBaseLayout( ).setEventConsumer( false );
           
           
// attach a listener allowing the y axis to be adjusted via the mouse
            yAxisLayout
.addGlimpseMouseAllListener( new AxisMouseListener1D( ) );
           
           
// add painters to the plotting area
            plotLayout
.addPainter( new BackgroundPainter( ) );
            plotLayout
.addPainter( new GridPainter( plot.getTimeAxisLabelHandler( ), axisLabels ).setShowMinorGrid( false ) );
            plotLayout
.addPainter( new BorderPainter( ) );
           
           
// add the layouts to the timeline row and position them with mig layout constraint strings
            plot1
.getBaseLayout( ).addLayout( yAxisLayout );
            plot1
.getBaseLayout( ).addLayout( plotLayout );
            yAxisLayout
.setLayoutData( String.format( "growy, pushy, width %d", labelSize ) );
            plotLayout
.setLayoutData( "grow, push" );


Geoffrey Ulman

unread,
Jun 21, 2016, 10:51:12 AM6/21/16
to Glimpse

Here's an example of what adding three rows set up using the above code might look like. The end result will be very similar to Mike's solution. So either is a reasonable approach to take.



ckocamanoglu

unread,
Jun 21, 2016, 11:09:15 AM6/21/16
to metsci-...@googlegroups.com
Below, it is the output when i apply the solution u shared. I was playing directly with NumericAxisXYPainter in order to find a workaround. Creating a plot (PlotInfo) and adding GlimpseAxisLayoutY to base layout worked as i expected


Thank you very much, Geoffrey, Mike and Brandon !!


On Tue, Jun 21, 2016 at 5:51 PM, Geoffrey Ulman <ul...@metsci.com> wrote:

Here's an example of what adding three rows set up using the above code might look like. The end result will be very similar to Mike's solution. So either is a reasonable approach to take.



--
You received this message because you are subscribed to a topic in the Google Groups "Glimpse" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/metsci-glimpse/EeDEJONmhKA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to metsci-glimps...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Çağlar
Reply all
Reply to author
Forward
0 new messages