1 Debian patch touch this file
-
Fix ivy dependencies.
- Author
- Bas Couwenberg <[email protected]>
- Bug
- https://josm.openstreetmap.de/ticket/24839
- Forwarded
- not-needed
| •1 | /* |
| 2 | * MIT License |
| 3 | * |
| 4 | * Copyright (c) 2023-2025 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.output.impl; |
| 23 | |
| 24 | import java.awt.*; |
| 25 | import java.awt.geom.AffineTransform; |
| 26 | |
| 27 | import org.jetbrains.annotations.NotNull; |
| 28 | |
| 29 | import com.github.weisj.jsvg.renderer.output.Output; |
| 30 | |
| 31 | /** |
| 32 | * A utility class that holds a {@link Graphics2D} object and is able to reset it back to its original configuration, |
| 33 | * as this is often more efficient than creating a new graphics instance. |
| 34 | * <p> |
| 35 | * This class does not track what parameters have been modified, nor does it reset all configuration parameters. Which |
| 36 | * parameters are reset should be expanded as needed. |
| 37 | */ |
| 38 | public class GraphicsResetHelper implements Output.SafeState { |
| 39 | |
| 40 | private final Graphics2D graphics; |
| 41 | |
| 42 | private final Composite originalComposite; |
| 43 | private final Paint originalPaint; |
| 44 | private final Stroke originalStroke; |
| 45 | private final AffineTransform originalTransform; |
| 46 | |
| 47 | public GraphicsResetHelper(@NotNull Graphics2D graphics) { |
| 48 | this.graphics = graphics; |
| 49 | |
| 50 | originalComposite = graphics.getComposite(); |
| 51 | originalPaint = graphics.getPaint(); |
| 52 | originalStroke = graphics.getStroke(); |
| 53 | originalTransform = graphics.getTransform(); |
| 54 | } |
| 55 | |
| 56 | public @NotNull Graphics2D graphics() { |
| 57 | return graphics; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public void restore() { |
| 62 | graphics.setComposite(originalComposite); |
| 63 | graphics.setPaint(originalPaint); |
| 64 | graphics.setStroke(originalStroke); |
| 65 | graphics.setTransform(originalTransform); |
| 66 | } |
| 67 | } |