| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.github.weisj.jsvg.renderer.impl.context; |
| 23 |
|
| 24 |
import java.awt.geom.AffineTransform; |
| 25 |
|
| 26 |
import org.jetbrains.annotations.NotNull; |
| 27 |
import org.jetbrains.annotations.Nullable; |
| 28 |
|
| 29 |
import com.github.weisj.jsvg.attributes.FillRule; |
| 30 |
import com.github.weisj.jsvg.attributes.PaintOrder; |
| 31 |
import com.github.weisj.jsvg.attributes.font.MeasurableFontSpec; |
| 32 |
import com.github.weisj.jsvg.attributes.font.SVGFont; |
| 33 |
import com.github.weisj.jsvg.nodes.prototype.Mutator; |
| 34 |
import com.github.weisj.jsvg.paint.SVGPaint; |
| 35 |
import com.github.weisj.jsvg.renderer.MeasureContext; |
| 36 |
import com.github.weisj.jsvg.renderer.PlatformSupport; |
| 37 |
import com.github.weisj.jsvg.renderer.RenderContext; |
| 38 |
import com.github.weisj.jsvg.view.ViewBox; |
| 39 |
|
| 40 |
public final class RenderContextAccessor { |
| 41 |
|
| 42 |
public interface Accessor { |
| 43 |
|
| 44 |
@NotNull |
| 45 |
RenderContext createInitial(@Nullable SVGPaint currentColor, @NotNull PlatformSupport awtSupport, |
| 46 |
@NotNull MeasureContext measureContext); |
| 47 |
|
| 48 |
@NotNull |
| 49 |
RenderContext deriveForSurface(@NotNull RenderContext context); |
| 50 |
|
| 51 |
@NotNull |
| 52 |
RenderContext deriveForChildGraphics(@NotNull RenderContext context); |
| 53 |
|
| 54 |
@NotNull |
| 55 |
RenderContext deriveForNode( |
| 56 |
@NotNull RenderContext context, |
| 57 |
@Nullable Mutator<PaintContext> paintContextMutator, |
| 58 |
@Nullable Mutator<MeasurableFontSpec> attributeFontSpec, |
| 59 |
@Nullable FontRenderContext frc, |
| 60 |
@Nullable ContextElementAttributes contextAttributes, |
| 61 |
@NotNull Object node); |
| 62 |
|
| 63 |
@NotNull |
| 64 |
RenderContext setupInnerViewRenderContext(@NotNull ViewBox viewBox, |
| 65 |
@NotNull RenderContext context, boolean inheritAttributes); |
| 66 |
|
| 67 |
@NotNull |
| 68 |
StrokeContext strokeContext(@NotNull RenderContext context); |
| 69 |
|
| 70 |
@NotNull |
| 71 |
FontRenderContext fontRenderContext(@NotNull RenderContext context); |
| 72 |
|
| 73 |
@NotNull |
| 74 |
FillRule fillRule(@NotNull RenderContext context); |
| 75 |
|
| 76 |
@NotNull |
| 77 |
PaintOrder paintOrder(@NotNull RenderContext context); |
| 78 |
|
| 79 |
@NotNull |
| 80 |
SVGFont font(@NotNull RenderContext context); |
| 81 |
|
| 82 |
@Nullable |
| 83 |
SVGPaint currentColor(@NotNull RenderContext context); |
| 84 |
|
| 85 |
void setRootTransform(@NotNull RenderContext context, @NotNull AffineTransform rootTransform); |
| 86 |
|
| 87 |
void setRootTransform(@NotNull RenderContext context, @NotNull AffineTransform rootTransform, |
| 88 |
@NotNull AffineTransform userSpaceTransform); |
| 89 |
} |
| 90 |
|
| 91 |
private static Accessor instance; |
| 92 |
|
| 93 |
static { |
| 94 |
try { |
| 95 |
Class.forName(RenderContext.class.getName()); |
| 96 |
} catch (ClassNotFoundException e) { |
| 97 |
throw new IllegalStateException(e); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
private RenderContextAccessor() {} |
| 102 |
|
| 103 |
public static Accessor instance() { |
| 104 |
if (instance == null) { |
| 105 |
throw new IllegalStateException("RenderContextAccessor not initialized"); |
| 106 |
} |
| 107 |
return instance; |
| 108 |
} |
| 109 |
|
| 110 |
public static void setInstance(Accessor accessor) { |
| 111 |
if (instance != null) { |
| 112 |
throw new IllegalStateException("RenderContextAccessor already initialized"); |
| 113 |
} |
| 114 |
instance = accessor; |
| 115 |
} |
| 116 |
} |