Debian Codegraph @

src/com/github/weisj/jsvg/renderer/impl/context/RenderContextAccessor.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*
2 * MIT License
3 *
4 * Copyright (c) 2025-2026 Jannis Weis
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7 * associated documentation files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
9 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all copies or
13 * substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
16 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 }