java.lang.Object
net.i2p.router.web.GraphThemeColors

public final class GraphThemeColorsextends Object
The display values a graph frame draws with, overridable per theme with CSS custom properties.

Seventeen variables cover every themed part of a tile: the two plot strokes and fills, the series dot pattern, both stroke widths, the text colour, the axis rules, both grids and their dot patterns, the plot background, the edge shading, the restart rule, and the gridline a tile too small for a minor grid keeps.

Fonts are the exception and are not here. A graph reads --monospaced and --bodyfont from the console's own font stylesheet, so a second pair here could only disagree with the page it is drawn on.

The stylesheet is the canonical statement of a theme's look. The values held in this class are one fallback set - light's, because light is the console's default look - reached only when a theme's stylesheet declares nothing at all: an unknown theme name, or a layout with no stylesheet. Neither case has a theme identity to honour, so nothing here is per-theme; anything that genuinely differs between themes differs in the CSS.

A theme opts in by declaring variables in its console.css:

:root{
  --graph_plotLine1:#64c8a0;
  --graph_plotFill1:#64c8a05a;
  --graph_plotDash:1.5;
  --graph_plotLineWidthWide:2.5;
}
Anything absent keeps the built-in default, so no theme has to be edited and a typo in one declaration costs that one value rather than the whole frame.

Not every stroke width is the theme's: GraphRenderer overrides it for a grouped axis, a crowded tile and the sidebar sparkline, because those are legibility decisions about one layout rather than a look.

Why the file is read server-side

A graph image is served as <img src="/viewstat.jsp?...">, which makes the SVG an isolated document: page CSS does not reach it and page custom properties are invisible inside. Declaring the variables in the SVG itself would only let a user edit a file they cannot reach, so the theme's own stylesheet is parsed here and the resolved values are handed to the renderer. That also means getComputedStyle is not involved and the minigraph's client-side path does not apply here.

Caching

One small file per theme, parsed at most once and held in a ConcurrentHashMap, since every graph tile on a console page asks for the same palette. Themes do not change while the router runs, so there is no invalidation hook; a theme edit takes effect on the next restart, the same as any other installed resource.
  • Field Details

    • THEME_SUBDIR

      public static final String THEME_SUBDIR
      Where the console keeps its themes, relative to the router base directory.

      docs/themes/console, which is where the theme picker scans (ConfigUIHelper) and where an installed router puts them - not under webapps, which holds the deployed console war. Getting this wrong is silent: every lookup takes the "no stylesheet" path and falls back to the built-in defaults, so a theme edit appears to do nothing at all.

      See Also:
    • VAR_PLOT_DASH

      public static final String VAR_PLOT_DASH
      Dash length, in pixels, of the multi-plot dot pattern; zero asks for a solid line.
      See Also:
    • VAR_TEXT_COLOR

      public static final String VAR_TEXT_COLOR
      Text colour: axis labels, tick labels, the legend and the title.
      See Also:
    • VAR_AXIS_COLOR

      public static final String VAR_AXIS_COLOR
      The two axis rules.
      See Also:
    • VAR_GRID_MINOR

      public static final String VAR_GRID_MINOR
      The minor gridlines.
      See Also:
    • VAR_GRID_MAJOR

      public static final String VAR_GRID_MAJOR
      The major gridlines.
      See Also:
    • VAR_GRID_MINOR_DASH

      public static final String VAR_GRID_MINOR_DASH
      Dot length for the minor gridlines; zero asks for solid gridlines.
      See Also:
    • VAR_GRID_MAJOR_DASH

      public static final String VAR_GRID_MAJOR_DASH
      Dot length for the major gridlines; zero asks for solid gridlines.
      See Also:
    • VAR_BACKGROUND

      public static final String VAR_BACKGROUND
      The plot area's own background, behind the gridlines.
      See Also:
    • VAR_EDGE_SHADE

      public static final String VAR_EDGE_SHADE
      The shading band drawn along the bottom and left edges of the plot area.
      See Also:
    • VAR_RESTART_MARKER

      public static final String VAR_RESTART_MARKER
      The vertical rule and legend entry marking a router restart.
      See Also:
    • VAR_GRID_COMPACT

      public static final String VAR_GRID_COMPACT
      The gridline a tile too small for a minor grid keeps, which is not necessarily either of its two grids: the shipped themes split on which one they would rather drop.
      See Also:
    • VAR_PLOT_LINE_WIDTH

      public static final String VAR_PLOT_LINE_WIDTH
      Stroke width, in pixels, of a plot line on a tile up to WIDE_WIDTH.
      See Also:
    • VAR_PLOT_LINE_WIDTH_WIDE

      public static final String VAR_PLOT_LINE_WIDTH_WIDE
      Stroke width, in pixels, of a plot line past WIDE_WIDTH, where the series is long enough that a thinner stroke breaks up into dashes.
      See Also:
    • VAR_PLOT_LINE_WIDTH_CONDENSED

      public static final String VAR_PLOT_LINE_WIDTH_CONDENSED
      Stroke width, in pixels, of a plot line on a narrow tile carrying condensed data.

      Distinct from VAR_PLOT_LINE_WIDTH because the ordinary weight is tuned for a series with room to separate. Pack the same number of points into a narrower frame and the polyline's segments crowd together, so the weight that reads well on a roomy plot fills in on a condensed one. Themes ship 2 here against 3 for the ordinary plot.

      See Also:
    • VAR_PLOT_LINE_WIDTH_FILLED

      public static final String VAR_PLOT_LINE_WIDTH_FILLED
      Stroke width, in pixels, of the line drawn over a filled plot.

      Its own variable because it is not the plot line. VAR_PLOT_LINE_WIDTH and its siblings state how heavy a plot line is; this one states how heavy the edge over a fill is, and the two are chosen for different jobs. It used to be half the plot width, which meant a theme could not set a readable fill edge without also reweighting every line plot in the console.

      See Also:
    • VAR_PLOT_LINE_WIDTH_FILLED_WIDE

      public static final String VAR_PLOT_LINE_WIDTH_FILLED_WIDE
      Stroke width, in pixels, of the line over a filled plot on a frame past WIDE_WIDTH.

      The filled family needs its own wide variant for the same reason the plot family does: a longer series shows a thinner stroke's gaps more readily. Without it a wide filled graph was stuck on the ordinary filled weight, so raising --graph_plotLineWidthWide did nothing there - the two families read separate variables, so a theme could not widen one without widening the other.

      See Also:
    • VAR_PLOT_LINE_WIDTH_FILLED_CONDENSED

      public static final String VAR_PLOT_LINE_WIDTH_FILLED_CONDENSED
      Stroke width, in pixels, of the line over a filled plot on a narrow, condensed frame.

      The third member of the filled family, matching the plot family's plain, wide and condensed. Without it the filled edge had only one weight, so a narrow filled graph drew the same edge as a roomy one - which is the crowding the condensed slot exists to answer, just on the filled path where it had no slot to answer it in.

      See Also:
    • WIDE_WIDTH

      public static final int WIDE_WIDTH
      Frame width, in pixels, past which VAR_PLOT_LINE_WIDTH_WIDE replaces VAR_PLOT_LINE_WIDTH.

      A layout constant rather than a theme choice: a tile is drawn wider when the console has room for it, and a longer series shows a thinner stroke's gaps more readily, so the two are the same decision seen from either end.

      See Also:
    • CONDENSED_WIDTH

      public static final int CONDENSED_WIDTH
      Frame width, in pixels, at or below which a condensed plot takes VAR_PLOT_LINE_WIDTH_CONDENSED.

      A layout constant, like WIDE_WIDTH: the question is whether the points have room to separate, which is a property of the frame rather than of the theme.

      See Also:
    • VAR_PLOT_LINE_PREFIX

      static final String VAR_PLOT_LINE_PREFIX
      Prefix of the per-plot stroke variables; --graph_plotLine1, --graph_plotLine2.
      See Also:
    • VAR_PLOT_FILL_PREFIX

      static final String VAR_PLOT_FILL_PREFIX
      Prefix of the per-plot fill variables; --graph_plotFill1, --graph_plotFill2.
      See Also:
    • PLOTS

      public static final int PLOTS
      Plots per frame. Two by contract: see GraphGroups.MAX_SERIES.
      See Also:
    • DECL

      private static final Pattern DECL
      Matches one custom property declaration, anywhere in the stylesheet.
    • LINEAR_GRADIENT

      private static final String LINEAR_GRADIENT
      The gradient function a fill variable may use; matched case-insensitively.
      See Also:
    • GRADIENT_DIRECTION

      private static final Pattern GRADIENT_DIRECTION
      A gradient's leading direction, which an area under a series does not paint.
    • DASH_SPLIT

      private static final Pattern DASH_SPLIT
      Dash-list separator: commas and/or whitespace.
    • WS_SPLIT

      private static final Pattern WS_SPLIT
      Space-separated stop separator; a stop may itself contain commas, so never split on those.
    • CACHE

      private static final Map<String, GraphThemeColors.Entry> CACHE
      Theme directory plus theme name to its parsed declarations.
    • NO_FILE

      private static final long NO_FILE
      Marker for "the stylesheet is not there", which is a cacheable state of its own.
      See Also:
    • maxCacheAgeMs

      static long maxCacheAgeMs
      How long a parse may be reused even when the timestamp looks unchanged, in ms.

      The timestamp check is what normally keeps this current, and it means an edit is visible on the very next page load. This interval is the fallback for a filesystem that does not maintain last-modified reliably - a network mount, some container overlays, or a coarse timestamp that hides two saves in the same second. Re-reading on a timer as well costs one small file read per interval, which is nothing next to rendering the graph itself.

      Not a static final so tests can shorten it instead of sleeping.

    • PLOT_LINE

      private static final Color[] PLOT_LINE
      Fallback stroke for each plot, used only when a theme declares no --graph_plotLine<N>.

      Light's pair, because light is the console's default look. A theme with a palette of its own states it in its own console.css, which is where the palette belongs: a derivation here could not also be canonical, since a stylesheet may declare any colour it likes.

    • PLOT_FILL

      private static final Color[] PLOT_FILL
      Fallback fill for each plot, used only when a theme declares no --graph_plotFill<N>.

      Light's pair, alpha included, for the reason given on PLOT_LINE.

      The fills are translucent because a frame carries two of them and they overlap wherever the series cross. At the 78-86% the fills used to carry, the crossing was so nearly opaque that neither series read through it - the shape you most want to see was the one you could not.

    • DEFAULT_DASH

      private static final float DEFAULT_DASH
      Fallback series dot length, used only when a theme declares no --graph_plotDash.

      Zero asks for a solid line, which is what a frame with no theme to be should draw. Every shipped theme asks for a solid series of its own, so none of them relies on it.

      See Also:
    • GRID_MINOR_DASH_DEFAULT

      private static final float[] GRID_MINOR_DASH_DEFAULT
      Fallback minor-gridline dot and gap, used only when a theme declares no --graph_gridMinorDash. A zero dot is a solid gridline.
    • GRID_MAJOR_DASH_DEFAULT

      private static final float[] GRID_MAJOR_DASH_DEFAULT
      Fallback major-gridline dot and gap, used only when a theme declares no --graph_gridMajorDash. A zero dot is a solid gridline.
    • TEXT_COLOR_DEFAULT

      private static final Color TEXT_COLOR_DEFAULT
      Fallback text colour, used only when a theme declares no --graph_textColor.
    • AXIS_COLOR_DEFAULT

      private static final Color AXIS_COLOR_DEFAULT
      Fallback axis rule colour, used only when a theme declares no --graph_axisColor.

      The text ink, since an axis carries the labels that sit along it.

    • GRID_MINOR_DEFAULT

      private static final Color GRID_MINOR_DEFAULT
      Fallback minor gridline colour, used only when a theme declares no --graph_gridMinor. Faint enough to sit behind the series.
    • GRID_MAJOR_DEFAULT

      private static final Color GRID_MAJOR_DEFAULT
      Fallback major gridline colour, used only when a theme declares no --graph_gridMajor. Twice the minor grid's weight, which is the whole of the difference from it.
    • BACKGROUND_DEFAULT

      private static final Color BACKGROUND_DEFAULT
      Fallback plot background, used only when a theme declares no --graph_background. Opaque, since it is what a frame with no stylesheet sits on.
    • EDGE_SHADE_DEFAULT

      private static final Color EDGE_SHADE_DEFAULT
      Fallback edge shading, used only when a theme declares no --graph_edgeShade.
    • RESTART_MARKER_DEFAULT

      private static final Color RESTART_MARKER_DEFAULT
      Fallback restart rule colour, used only when a theme declares no --graph_restartMarker.
    • GRID_COMPACT_DEFAULT

      private static final Color GRID_COMPACT_DEFAULT
      Fallback gridline for a tile too small for a minor grid, used only when a theme declares no --graph_gridCompact. Light's, which is its major grid.
    • PLOT_LINE_WIDTH_DEFAULT

      private static final float PLOT_LINE_WIDTH_DEFAULT
      Fallback plot-line stroke width, used only when a theme declares no --graph_plotLineWidth.

      Light's, and what every shipped theme declares today. The renderer has separate reasons to draw a thinner or thicker line - a dense tile, the sidebar sparkline - and those stay in GraphRenderer rather than here: they are legibility decisions about one layout, not something a theme picks.

      Pinned to what every shipped theme declares, so a console whose stylesheet cannot be read draws its plots the same weight as one that can.

      See Also:
    • PLOT_LINE_WIDTH_WIDE_DEFAULT

      private static final float PLOT_LINE_WIDTH_WIDE_DEFAULT
      Fallback plot-line stroke width past WIDE_WIDTH, used only when a theme declares no --graph_plotLineWidthWide.

      Equal to PLOT_LINE_WIDTH_DEFAULT, which is what the width rule did before either variable existed. The two are separate so a theme can weight a long series more heavily without changing the rest of the console.

      Was 2.5 while every shipped theme declared 4, for the same reason as PLOT_LINE_WIDTH_DEFAULT.

      See Also:
    • PLOT_LINE_WIDTH_CONDENSED_DEFAULT

      private static final float PLOT_LINE_WIDTH_CONDENSED_DEFAULT
      Fallback plot-line stroke width for a narrow, condensed plot, used only when a theme declares no --graph_plotLineWidthCondensed.

      Equal to PLOT_LINE_WIDTH_DEFAULT, so a theme that says nothing about the condensed case gets the same weight as an ordinary plot and only the themes that declare the variable opt into the thinner condensed weight.

      See Also:
    • PLOT_LINE_WIDTH_FILLED_DEFAULT

      private static final float PLOT_LINE_WIDTH_FILLED_DEFAULT
      Fallback stroke width for the line over a filled plot, used only when a theme declares no --graph_plotLineWidthFilled.

      What the old half-the-plot-width rule produced for every shipped theme, so a theme that omits the variable draws the same edge it drew before the variable existed.

      See Also:
    • PLOT_LINE_WIDTH_FILLED_WIDE_DEFAULT

      private static final float PLOT_LINE_WIDTH_FILLED_WIDE_DEFAULT
      Fallback for VAR_PLOT_LINE_WIDTH_FILLED_WIDE, used only when a theme declares no such variable.

      What the old half-the-plot-width rule produced for a wide plot of every shipped theme (4 × 0.5), so an ordinary theme draws the same wide filled edge it drew before the variable existed.

      See Also:
    • PLOT_LINE_WIDTH_FILLED_CONDENSED_DEFAULT

      private static final float PLOT_LINE_WIDTH_FILLED_CONDENSED_DEFAULT
      Fallback for VAR_PLOT_LINE_WIDTH_FILLED_CONDENSED, used only when a theme declares no such variable.

      Two thirds of PLOT_LINE_WIDTH_FILLED_DEFAULT, the same step the plot family takes from its ordinary width to its condensed one (2 of 3). The old coupled rule gave a condensed filled edge the ordinary filled weight, which is what made a narrow filled graph look heavy.

      See Also:
    • MIN_LINE_WIDTH

      private static final float MIN_LINE_WIDTH
      Bounds on a declared stroke width: a hairline is not a line, and a width past the point of covering the data is not a theme's to choose.
      See Also:
    • MAX_LINE_WIDTH

      private static final float MAX_LINE_WIDTH
      Largest line width of the graphs.
      See Also:
    • MAX_DASH_VALUES

      private static final int MAX_DASH_VALUES
      Longest dash array accepted: one dot and one gap.
      See Also:
  • Constructor Details

    • GraphThemeColors

      private GraphThemeColors()
      Not called, the class is only a collection of static methods.
  • Method Details

    • defaultLine

      private static Color defaultLine(int plot)
      Fallback stroke for a plot.
      Parameters:
      plot - the plot ordinal
      Returns:
      the built-in stroke, used when the theme declares no --graph_plotLine<N>
    • defaultPath

      private static Color defaultPath(int plot)
      Fallback fill for a plot.
      Parameters:
      plot - the plot ordinal
      Returns:
      the built-in fill, used when the theme declares no --graph_plotFill<N>
    • lineColor

      public static Color lineColor(File themeDir, String theme, int plot)
      The stroke colour for a plot on a frame.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      plot - the plot ordinal, 0 for the first line and 1 for the second
      Returns:
      the colour, never null; falls back to the built-in value
    • lineValueShade

      public static Color[] lineValueShade(File themeDir, String theme, int plot)
      The stops that shade plot lines by their value, or null when lines are drawn flat.

      A plot line's declaration is read for this as well as for lineColor(File, String, int), so a theme opts in by naming two or more colours where it used to name one:

        --graph_plotLine1:#2ec23e40 #f0000008 #d0000008;
      

      The line is then drawn with a vertical gradient across the plot area, so the colour at a point is the colour for the value at that point - height is the value. The declared single colour still does its other jobs: it is the legend swatch, and it is what is drawn when the plot area is too short to span.

      Read per plot, so the two lines on one axis are shaded independently like every other plot colour. A theme can shade one line by value and leave the other flat.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      plot - the plot ordinal, 0 for the first line and 1 for the second
      Returns:
      bottom-to-top stops, or null when the theme named one colour or fewer
    • pathColor

      public static Color pathColor(File themeDir, String theme, int plot)
      The fill colour for a plot on a frame.

      A linear-gradient() declaration has no single colour, so its first stop is reported here: that is the ink the fill is made of. pathPaint(File, String, int, int) returns the whole wash.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      plot - the plot ordinal, 0 for the first path and 1 for the second
      Returns:
      the colour, never null; falls back to the built-in value
    • pathPaint

      public static Paint pathPaint(File themeDir, String theme, int plot, int frameHeight)
      The fill for a plot as something to paint with: a colour, or a vertical gradient.

      A gradient needs a length to span, and the area under a series is a vertical wash, so the frame's height is the caller's to supply. Only the CSS default direction - top to bottom, which is what the minigraph's own fill variables use - is painted; a stated direction this class cannot honour is treated as no opinion rather than a guess, and the fill comes out as its ink.

      Two stops are painted as a GradientPaint and three or more as a LinearGradientPaint, which is the only one of the two that holds an arbitrary number. Either way the stops are spread evenly down the span, so a third stop lands a third of the way down rather than wherever the declaration happened to say.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      plot - the plot ordinal, 0 for the first path and 1 for the second
      frameHeight - the height of the frame in pixels, which a gradient spans
      Returns:
      the fill paint, never null; falls back to the built-in colour
    • dashLength

      public static float dashLength(File themeDir, String theme)
      The dot ink length for the pattern that distinguishes the second plot from the first.

      --graph_plotDash takes either a bare length or a CSS dash pair:

        --graph_plotDash:1        a 1px dot, gap derived from the line width
        --graph_plotDash:1 3      a 1px dot followed by 3px of space
        --graph_plotDash:1,3      the same, for a comma-separated habit
        --graph_plotDash:0        no pattern at all: a solid line
        --graph_plotDash:0 3      the same; a gap needs a dot to follow it
      
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the dot length in pixels, or zero when the stylesheet asked for a solid line
    • dashGap

      public static float dashGap(File themeDir, String theme)
      The space after each dot, as stated by the theme, or zero when the renderer should derive it from the line width.

      A stated value is not a promise: RrdGraphConstants raises anything too tight to keep the dots apart, because with round caps each dot lays down dot + width of ink and a gap at or below the width merges them into a solid line. Reporting the raw value keeps this class a plain reader of the stylesheet.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the stated gap in pixels, or zero to derive one
    • element

      private static Color element(File themeDir, String theme, String var, Color fallback)
      One frame element's colour: the theme's, or the built-in fallback.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      var - the custom property the element reads
      fallback - the built-in colour, used when the theme declares nothing usable
      Returns:
      the colour, never null
    • textColor

      public static Color textColor(File themeDir, String theme)
      The text colour: axis labels, tick labels, the legend and the title.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • axisColor

      public static Color axisColor(File themeDir, String theme)
      The axis rule colour.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • gridMinorColor

      public static Color gridMinorColor(File themeDir, String theme)
      The minor gridline colour.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • gridMajorColor

      public static Color gridMajorColor(File themeDir, String theme)
      The major gridline colour.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • gridMinorDash

      public static float gridMinorDash(File themeDir, String theme)
      Dot length for the minor gridlines, or zero for solid ones.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the dot length in pixels
    • gridMinorDashGap

      public static float gridMinorDashGap(File themeDir, String theme)
      The space after each minor gridline dot, or zero to derive it from the stroke width.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the stated gap in pixels, or zero to derive one
    • gridMajorDash

      public static float gridMajorDash(File themeDir, String theme)
      Dot length for the major gridlines, or zero for solid ones.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the dot length in pixels
    • gridMajorDashGap

      public static float gridMajorDashGap(File themeDir, String theme)
      The space after each major gridline dot, or zero to derive it.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the stated gap in pixels, or zero to derive one
    • backgroundColor

      public static Color backgroundColor(File themeDir, String theme)
      The plot area's own background: the rectangle behind the gridlines.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • edgeShadeColor

      public static Color edgeShadeColor(File themeDir, String theme)
      The shading band along the bottom and left edges of the plot area.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null; fully transparent where a theme drops the band
    • restartMarkerColor

      public static Color restartMarkerColor(File themeDir, String theme)
      The vertical rule and legend entry marking a router restart.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • compactGridColor

      public static Color compactGridColor(File themeDir, String theme)
      The gridline a tile too small for a minor grid keeps in place of the minor grid.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the colour, never null
    • plotLineWidth

      public static float plotLineWidth(File themeDir, String theme)
      Stroke width of a plot line on a tile no wider than WIDE_WIDTH.

      A renderer decision outranks this one - see GraphRenderer for the dense-tile and sparkline widths - so a theme sets the weight of an ordinary plot, not every plot.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
    • plotLineWidthWide

      public static float plotLineWidthWide(File themeDir, String theme)
      Stroke width of a plot line on a tile wider than WIDE_WIDTH.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
      See Also:
    • plotLineWidthCondensed

      public static float plotLineWidthCondensed(File themeDir, String theme)
      Stroke width of a plot line on a tile no wider than CONDENSED_WIDTH that carries condensed data.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
      See Also:
    • plotLineWidthFilled

      public static float plotLineWidthFilled(File themeDir, String theme)
      Stroke width of the line drawn over a filled plot.

      Independent of plotLineWidth(File, String) and its siblings: this is an edge on a fill, not a plot line, and the two are set for different reasons.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
      See Also:
    • plotLineWidthFilledWide

      public static float plotLineWidthFilledWide(File themeDir, String theme)
      Stroke width of the line over a filled plot on a frame wider than WIDE_WIDTH.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
      See Also:
    • plotLineWidthFilledCondensed

      public static float plotLineWidthFilledCondensed(File themeDir, String theme)
      Stroke width of the line over a filled plot on a narrow, condensed frame.
      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the width in pixels, never zero or negative
      See Also:
    • length

      private static float length(File themeDir, String theme, String var, float fallback)
      One declared length, bounded, or the built-in fallback.

      An absent variable and an unusable one are the same case on purpose: both mean the theme has no opinion, so both fall back rather than failing the render.

      Parameters:
      themeDir - the console themes root holding the theme's CSS
      theme - the console theme name whose variables are read
      var - the CSS custom property name to look up
      fallback - the built-in width, used when the variable is absent or out of range
      Returns:
      the width in pixels, within MIN_LINE_WIDTH and MAX_LINE_WIDTH
    • dash

      private static float[] dash(File themeDir, String theme, String var, float[] fallback)
      Parse a dash variable into a dot length and a stated gap.
      Parameters:
      themeDir - the console themes root holding the theme's CSS
      theme - the console theme name whose variables are read
      var - the CSS custom property name to look up
      fallback - the built-in {dot, gap}, used when the variable is absent or unusable
      Returns:
      {dot, gap}, with a dot of zero meaning "no pattern" and a gap of zero meaning "derive it"; never null
    • dash

      private static float[] dash(File themeDir, String theme)
      Parse --graph_plotDash into a dot length and a stated gap.
      Parameters:
      themeDir - the console themes root holding the theme's CSS
      theme - the console theme name whose variables are read
      Returns:
      {dot, gap}, with a dot of zero meaning "no pattern" and a gap of zero meaning "derive it"; never null
    • parseDashList

      private static float[] parseDashList(String value)
      Read one or two whitespace- or comma-separated lengths.

      Longer lists are refused rather than truncated. CSS would cycle an odd-length stroke-dasharray to make it even, but the minimum-gap rule below is stated for a single dot and gap, and silently dropping the rest would render something the stylesheet never asked for.

      Parameters:
      value - the raw variable text, one or two lengths separated by whitespace or commas
      Returns:
      the values, or null when the text is not a usable dash list
    • clampPlot

      private static int clampPlot(int plot)
      Limits the plot index to the color range.
      Parameters:
      plot - the index of the plot
      Returns:
      the index within the colors
    • declared

      private static Color declared(File themeDir, String theme, String var)
      The colour a theme declared, or null when it declared nothing usable.

      An absent variable and an unparseable one are the same case on purpose: both mean "this theme has no opinion about this slot", so both fall back to the default.

      Parameters:
      themeDir - the console themes root holding the theme's CSS
      theme - the console theme name whose variables are read
      var - the CSS custom property name to look up
      Returns:
      the parsed colour, or null if the theme omits var or names an unparseable value
    • declaredInk

      private static Color declaredInk(String value)
      The ink a declaration names: a colour, or the first stop of a gradient.

      A gradient is a wash rather than a colour, so a caller that wants one colour - a legend swatch, an alpha check - gets the ink the wash is made of.

      Parameters:
      value - the raw declaration text, a colour or a gradient, null yields null
      Returns:
      the colour named, or null if value is null or names nothing parseable
    • gradientStops

      private static List<Color> gradientStops(String value)
      The colour stops of a linear-gradient() declaration, in the order written.

      A leading direction is skipped rather than obeyed: an area under a series is a vertical wash, so only the endpoints say anything, and a direction this class cannot paint is a no-op rather than a guess. A stop's stated position is dropped for the same reason - it moves where the middle of the wash sits, not which inks it is between.

      Parameters:
      value - the raw declaration text, a linear-gradient() or a bare colour list
      Returns:
      the stops, or null when the value is not a gradient this class paints
    • splitGradientStops

      private static String[] splitGradientStops(String body)
      Split a gradient's own stop list on its commas, ignoring commas inside parentheses.

      A plain split would cut rgba(0,0,0,.5) into three fragments that parse as nothing, which discarded the whole declaration and quietly drew a flat colour instead of the gradient that was asked for. Splitting on top-level commas only keeps a colour function intact, so the two spellings accept the same set of colours.

      Parameters:
      body - the text between linear-gradient( and its closing bracket
      Returns:
      the stop expressions, which still need their colour parsed
    • parseStops

      private static List<Color> parseStops(String[] terms, boolean gradient)
      Colours from already-split terms, dropping a direction keyword where one is allowed.
      Parameters:
      terms - the split declaration terms, each a colour or a direction keyword
      gradient - true for a linear-gradient() stop list, where a leading direction keyword is allowed and has to be skipped
      Returns:
      the colours, or null when any term is unusable or nothing remains
    • installedThemeDir

      public static File installedThemeDir()
      The directory the console is installed into, taken from the running context.
      Returns:
      the theme directory, or null when there is no context (unit tests, shutdown)
    • variables

      private static Map<String,String> variables(File themeDir, String theme)
      The theme's declarations, re-parsed whenever the stylesheet changes.

      A cached entry is reused while the file's last-modified stamp is unchanged and the entry is younger than maxCacheAgeMs, so the cost of a warm lookup is one stat() rather than a re-read. The stamp is checked before the cache is consulted for a second reason: a stylesheet that did not exist on an earlier lookup must not be remembered as empty forever, or a theme deployed after startup would never take effect.

      Parameters:
      themeDir - the directory holding <theme>/console.css trees
      theme - the console theme name
      Returns:
      the declarations, empty when the stylesheets are absent
    • stamp

      private static long stamp(File file)
      Read a file's stamp, treating an absent file as its own cacheable state.
      Parameters:
      file - the stylesheet to stat, null counts as absent
      Returns:
      the last-modified time, or NO_FILE
    • parse

      private static Map<String,String> parse(File css)
      Read a theme's stylesheet and collect its custom properties.
      Parameters:
      css - the stylesheet to read, null or absent yields an empty map
      Returns:
      the declarations, empty when the file is absent or unreadable, which is the normal case in a source checkout where the theme lives under installer/
    • themeFile

      private static File themeFile(File themeDir, String theme)
      Locate a theme's console.css.
      Parameters:
      themeDir - the installed themes root, null when there is none
      theme - the console theme name, null or empty matches nothing
      Returns:
      the file, or null when there is no theme directory to look in
    • clearCache

      static void clearCache()
      Forget every parsed theme.

      Not needed in normal operation: both the timestamp and the interval already pick up edits. This exists so a caller that has just rewritten a stylesheet can force a re-read without waiting.