Class MatrixGanger

java.lang.Object
uk.ac.starlink.ttools.plot2.geom.MatrixGanger
All Implemented Interfaces:
Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>

public class MatrixGanger extends Object implements Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
Ganger for use with a square matrix of Plane plots. Histogram-like plots are expected on the diagonal, and scatter-plot like plots on the off-diagonal cells. For a matrix of linear size N, there are only N spatial coordinates, all the X coordinates in the same column and all the Y coordinates in the same row are the same, with the exception of the count-dimension of diagonal (histogram-like) cells.
Since:
1 Jun 2023
Author:
Mark Taylor
  • Field Details

    • XDIAG

      public static final boolean XDIAG
      True if the histogram-like plots on the diagonal are considered to share their X coordinate with other cells in the same column; false if they are considered to share their Y coordinate with other cells in the same row. Has to be true, since known histogram-like layers assume the data coordinate is horizontal.
      See Also:
  • Constructor Details

    • MatrixGanger

      public MatrixGanger(MatrixShape shape, Padding padding, boolean isSquares, int cellGap)
      Constructor.
      Parameters:
      shape - defines which cells contain plots
      padding - padding round the outside of the gang
      isSquares - true if all zones are constrained to be square
      cellGap - gap in pixels between grid cells
  • Method Details

    • getShape

      public MatrixShape getShape()
      Returns the shape used by this ganger.
      Returns:
      matrix shape
    • getZoneCount

      public int getZoneCount()
      Description copied from interface: Ganger
      Returns the number of zones in gangs produced by this ganger.
      Specified by:
      getZoneCount in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Returns:
      zone count
    • isTrimmingGlobal

      public boolean isTrimmingGlobal()
      Description copied from interface: Ganger
      Indicates whether Trimming objects (legend and title) are to be applied to each zone individually or to the whole plot. For a single-zone ganger it ought not to make a difference, but false should be returned.
      Specified by:
      isTrimmingGlobal in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Returns:
      true for per-gang trimmings, false for per-zone trimmings
      See Also:
    • isShadingGlobal

      public boolean isShadingGlobal()
      Description copied from interface: Ganger
      Indicates whether shared Aux colour ramps are to be applied to each zone individually or to the whole plot. For a single-zone ganger it ought not to make a difference, but false should be returned.
      Specified by:
      isShadingGlobal in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Returns:
      true for per-gang shade axis, false for per-zone shade axis
      See Also:
    • createGang

      public Gang createGang(Rectangle[] zonePlotBounds)
      Description copied from interface: Ganger
      Creates a gang given the graphics coordinates of the individual zones. This can be used if the layout of the zones is already known.

      The supplied rectangle arguments give the bounds of the data area for each zone. This does not include any space for axis labels and other annotations, which are assumed to be available as required.

      Specified by:
      createGang in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Parameters:
      zonePlotBounds - array of data bounds, one for each zone
      Returns:
      new gang
    • createApproxGang

      public Gang createApproxGang(Rectangle gangExtBox)
      Description copied from interface: Ganger
      Constructs an approximate gang instance given only minimal information. This may be sufficient for passing the user a visual indication of roughly how zones are arranged, or making initial guesses at zone dimensions.
      Specified by:
      createApproxGang in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Parameters:
      gangExtBox - total area enclosing all zones and associated axis labels, annotations etc
      Returns:
      new approximate gang
    • createGang

      public Gang createGang(Rectangle gangExtBox, SurfaceFactory<PlaneSurfaceFactory.Profile,PlaneAspect> surfFact, ZoneContent<PlaneSurfaceFactory.Profile,PlaneAspect>[] zoneContents, Trimming[] trimmings, ShadeAxis[] shadeAxes, boolean withScroll)
      Description copied from interface: Ganger
      Creates a gang given the external bounds for the whole plotting area and other required information that characterises each zone. The supplied aspects are not modified by this method; any required aspect resolution should be performed before calling it.

      The form of the trimmings and shadeAxes arrays are as determined by the Ganger.isTrimmingGlobal() and Ganger.isShadingGlobal() methods; the length of each respective array must be one for the global case, and the same as the length of the zoneContents array in the per-zone case.

      Specified by:
      createGang in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Parameters:
      gangExtBox - total area enclosing all zones and associated axis labels, annotations etc
      surfFact - surface factory
      zoneContents - plot content for each zone (nz-element array)
      trimmings - additional decorations (1- or nz-element array, elements may be null)
      shadeAxes - shading axes (1- or nz-element array, elements may be null)
      withScroll - true if the positioning should work well even after some user scrolling
      Returns:
      new gang
    • adjustAspects

      public PlaneAspect[] adjustAspects(PlaneAspect[] aspects, int iz0)
      Description copied from interface: Ganger
      Adjusts plot surface aspects as required to ensure that plot data regions in a ganged set of zones are consistent.

      If a reference index greater than or equal to zero is supplied, this denotes the "master" zone, to which the other aspects should be adjusted. Otherwise, the aspects should be adjusted more democratically, treating all their requirements equally. With a reference index the other aspects might be adjusted to equal the master one, and without they might all be adjusted to cover the union of the ranges defined. If the reference index is >= the number of zones, behaviour is undefined.

      Specified by:
      adjustAspects in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Parameters:
      aspects - unadjusted aspects
      iz0 - index of reference aspect in array, or -1 for no reference
      Returns:
      array of consistent aspects based on input array, same size as input
    • adjustProfiles

      public PlaneSurfaceFactory.Profile[] adjustProfiles(PlaneSurfaceFactory.Profile[] profiles)
      Description copied from interface: Ganger
      Adjusts plot surface profiles as required for plots appearing in multiple plots within a gang.
      Specified by:
      adjustProfiles in interface Ganger<PlaneSurfaceFactory.Profile,PlaneAspect>
      Parameters:
      profiles - unadjusted profiles
      Returns:
      array of consistent profiles based on input array, same size as input