# Class AbstractZoneController<P,A>

java.lang.Object
uk.ac.starlink.topcat.plot2.AbstractZoneController<P,A>

All Implemented Interfaces:
  `Configger, ZoneController<P,A>`

public abstract class AbstractZoneController<P,A> extends Object implements ZoneController<P,A>
Partial ZoneController implementation.

Since:
  18 Aug 2023
Author:
  Mark Taylor

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractZoneController(uk.ac.starlink.ttools.plot2.SurfaceFactory<P,A> surfFact)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`clearRange(P oldProfile, P newProfile, uk.ac.starlink.ttools.plot2.PlotLayer[] oldLayers, uk.ac.starlink.ttools.plot2.PlotLayer[] newLayers, boolean lock)`
Indicates whether a new configuration should result in clearing the current ranges and plot aspect.
`protected abstract boolean`
`forceClearRange(P oldProfile, P newProfile)`
Determines whether the change between two profiles forces an unconditional re-range of the plotting surface.
`A`
`getAspect()`
Returns the plot aspect to use for setting up the plot surface.
`uk.ac.starlink.ttools.plot2.Navigator<A>`
`getNavigator()`
Returns the navigator specified by this control.
`uk.ac.starlink.ttools.plot.Range[]`
`getRanges()`
Returns the current fixed data coordinate ranges.
`void`
`setAspect(A aspect)`
Sets the plot aspect which defines the view on the data.
`void`
`setLatestSurface(uk.ac.starlink.ttools.plot2.Surface surface)`
Accepts information about the latest plotting surface to be plotted by the panel associated with this controller.
`void`
`setRanges(uk.ac.starlink.ttools.plot.Range[] ranges)`
Sets fixed data position coordinate ranges.
`void`
`submitReports(Map<LayerId, uk.ac.starlink.ttools.plot2.ReportMap> reports)`
Accepts report information generated by plotting layers.
`void`
`updateState(P profile, uk.ac.starlink.ttools.plot2.PlotLayer[] layers, boolean axisLock)`
Configures this controller for a given set of plot layers.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface Configger

`getConfig`

### Methods inherited from interface ZoneController

`clearAspect`

## Constructor Details

### AbstractZoneController

protected AbstractZoneController(uk.ac.starlink.ttools.plot2.SurfaceFactory<P,A> surfFact)
Constructor.

Parameters:
  `surfFact` - surface factory

## Method Details

### setRanges

public void setRanges(uk.ac.starlink.ttools.plot.Range[] ranges)
Sets fixed data position coordinate ranges. If these are not set then they may need to be calculated by examining the data to work out the plot aspect. Setting them to null ensures a re-range if required next time.

Specified by:
  `setRanges` in interface `ZoneController<P,A>`
Parameters:
  `ranges` - fixed data position coordinate ranges, or null to clear

### getRanges

public uk.ac.starlink.ttools.plot.Range[] getRanges()
Returns the current fixed data coordinate ranges. If not known, null is returned.

Specified by:
  `getRanges` in interface `ZoneController<P,A>`
Returns:
  fixed data position coordinate ranges, or null if not known

### setAspect

public void setAspect(A aspect)
Sets the plot aspect which defines the view on the data. If not set, it may have to be worked out from config and range inputs.

Specified by:
  `setAspect` in interface `ZoneController<P,A>`
Parameters:
  `aspect` - fixed aspect, or null to clear

### getAspect

public A getAspect()
Returns the plot aspect to use for setting up the plot surface. If not known, null is returned.

Specified by:
  `getAspect` in interface `ZoneController<P,A>`
Returns:
  fixed aspect, or null if none set

### updateState

public void updateState(P profile, uk.ac.starlink.ttools.plot2.PlotLayer[] layers, boolean axisLock)
Configures this controller for a given set of plot layers. This may trigger a resetting of the aspect and ranges, generally if the new plot is sufficiently different from most recent one. Whether that's the case is determined by calling `clearRange`.

This isn't perfect, since it only allows to clear the range or not. Sometimes you might want finer control, e.g. to clear the range in one dimension and retain it in others. It may be possible to fit that into the updateState API, but it would require more work.

Specified by:
  `updateState` in interface `ZoneController<P,A>`
Parameters:
  `profile` - surface profile
  `layers` - layers which will be plotted
  `axisLock` - whether re-ranging is inhibited; normally, if true axes will not be reset by this method, but the implementation can override that if it needs to

### submitReports

public void submitReports(Map<LayerId, uk.ac.starlink.ttools.plot2.ReportMap> reports)
Accepts report information generated by plotting layers. Null map values are permitted, with the same meaning as an empty map.

The default implementation does nothing, but subclasses may override it to enquire about plot results.

Specified by:
  `submitReports` in interface `ZoneController<P,A>`
Parameters:
  `reports` - per-layer plot reports for layers generated by the most recent plot

### setLatestSurface

public void setLatestSurface(uk.ac.starlink.ttools.plot2.Surface surface)
Accepts information about the latest plotting surface to be plotted by the panel associated with this controller. This method is intended for passing information back to this controller, which does not otherwise have access to the asynchronously constructed Surface object it has configured, it is not an instruction to adjust the current state.

The default implementation does nothing, but subclasses may override it to acquire information about plot state.

Specified by:
  `setLatestSurface` in interface `ZoneController<P,A>`
Parameters:
  `surface` - latest plotting surface.

### getNavigator

public uk.ac.starlink.ttools.plot2.Navigator<A> getNavigator()
Returns the navigator specified by this control.

Specified by:
  `getNavigator` in interface `ZoneController<P,A>`
Returns:
  current navigator

### clearRange

protected boolean clearRange(P oldProfile, P newProfile, uk.ac.starlink.ttools.plot2.PlotLayer[] oldLayers, uk.ac.starlink.ttools.plot2.PlotLayer[] newLayers, boolean lock)
Indicates whether a new configuration should result in clearing the current ranges and plot aspect.

Parameters:
  `oldProfile` - profile for last plot
  `newProfile` - profile for next plot
  `oldLayers` - layer set for last plot
  `newLayers` - layer set for next plot
  `lock` - whether re-ranging is inhibited; normally, if `lock` is true this method should return false, but the implementation can overrule this and return true even when locked if it needs to
Returns:
  true iff the range should be re-established for the next plot

### forceClearRange

protected abstract boolean forceClearRange(P oldProfile, P newProfile)
Determines whether the change between two profiles forces an unconditional re-range of the plotting surface. This method should return true if the plotting surface will change between the old and new supplied profiles sufficiently to invalidate previously calculated auto range data.

Parameters:
  `oldProfile` - profile before change
  `newProfile` - profile after change
Returns:
  true if a new auto-ranging is required