|
| 1 | +/* |
| 2 | + * Copyright (c) 2021. JetBrains s.r.o. |
| 3 | + * Use of this source code is governed by the MIT license that can be found in the LICENSE file. |
| 4 | + */ |
| 5 | + |
| 6 | +package org.jetbrains.letsPlot.geom |
| 7 | + |
| 8 | +import org.jetbrains.letsPlot.Geom.blank |
| 9 | +import org.jetbrains.letsPlot.Geom.point |
| 10 | +import org.jetbrains.letsPlot.Stat |
| 11 | +import org.jetbrains.letsPlot.intern.Layer |
| 12 | +import org.jetbrains.letsPlot.intern.layer.* |
| 13 | +import org.jetbrains.letsPlot.intern.layer.geom.PointAesthetics |
| 14 | +import org.jetbrains.letsPlot.intern.layer.geom.PointMapping |
| 15 | +import org.jetbrains.letsPlot.pos.positionIdentity |
| 16 | +import org.jetbrains.letsPlot.spatial.SpatialDataset |
| 17 | +import org.jetbrains.letsPlot.tooltips.TooltipOptions |
| 18 | + |
| 19 | +@Suppress("ClassName") |
| 20 | +/** |
| 21 | + * Draws nothing, but can be a useful way of ensuring common scales between different plots (see `expandLimits()`). |
| 22 | + * Also, can help to avoid the "No layers in plot" error when building plots using automated tools. |
| 23 | + * |
| 24 | + * @param data The data to be displayed in this layer. If null, the default, the data |
| 25 | + * is inherited from the plot data as specified in the call to [letsPlot][org.jetbrains.letsPlot.letsPlot]. |
| 26 | + * @param stat The statistical transformation to use on the data for this layer. |
| 27 | + * Supported transformations: `Stat.identity`, `Stat.bin()`, `Stat.count()`, etc. see [Stat][org.jetbrains.letsPlot.Stat]. |
| 28 | + * @param position Position adjustment: `positionIdentity`, `positionStack()`, `positionDodge()`, etc. see |
| 29 | + * [Position](https://lets-plot.org/kotlin/-lets--plot--kotlin/org.jetbrains.letsPlot.pos/). |
| 30 | + * @param showLegend default = true. |
| 31 | + * false - do not show legend for this layer. |
| 32 | + * @param inheritAes default = false. |
| 33 | + * false - do not combine the layer aesthetic mappings with the plot shared mappings. |
| 34 | + * @param manualKey String or result of the call to the `layerKey()` function. |
| 35 | + * The key to show in the manual legend. Specifies the text for the legend label or advanced settings using the `layerKey()` function. |
| 36 | + * @param sampling Result of the call to the `samplingXxx()` function. |
| 37 | + * To prevent any sampling for this layer pass value `samplingNone`. |
| 38 | + * For more info see [sampling.html](https://lets-plot.org/kotlin/sampling.html). |
| 39 | + * @param tooltips Result of the call to the `layerTooltips()` function. |
| 40 | + * Specifies appearance, style and content. |
| 41 | + * @param orientation Specifies the axis that the layer's stat and geom should run along, default = "x". |
| 42 | + * Possible values: "x", "y". |
| 43 | + * @param map Data-structure containing series of planar shapes and, optionally, associates data series (for example: |
| 44 | + * names of States and their boundaries). |
| 45 | + * |
| 46 | + * Supported shapes: Point and MultiPoint. |
| 47 | + * All coordinates should be encoded as decimal degrees in WGS84 coordinate reference system. |
| 48 | + * |
| 49 | + * Can be used with parameter `mapJoin` for joining data and map coordinates. |
| 50 | + * @param mapJoin Pair of Names or Pair of Lists of Names. |
| 51 | + * Specifies column names to join the `data` and the `map` coordinates on. |
| 52 | + * - Pair.first: column name or list of column names in the `data` dataframe. |
| 53 | + * - Pair.second: column name or list of column names in the `map` dataframe. |
| 54 | + * @param useCRS By default, all coordinates are converted into degrees of longitude and latitude, |
| 55 | + * and these map coordinates are projected onto the screen coordinates using Mercator projection. |
| 56 | + * Specify useCRS = "provided" to keep the SpatialDataset's original coordinate reference system (CRS). |
| 57 | + * @param x X-axis value. |
| 58 | + * @param y Y-axis value. |
| 59 | + * @param alpha Transparency level of a layer. Understands numbers between 0 and 1. |
| 60 | + * @param color Color of the geometry. |
| 61 | + * For more info see: [aesthetics.html#color-and-fill](https://lets-plot.org/kotlin/aesthetics.html#color-and-fill). |
| 62 | + * @param fill Color to paint shape's inner points. |
| 63 | + * Is applied only to the points of shapes having inner points. |
| 64 | + * For more info see: [aesthetics.html#color-and-fill](https://lets-plot.org/kotlin/aesthetics.html#color-and-fill). |
| 65 | + * @param shape Shape of the point. |
| 66 | + * For more info see: [aesthetics.html#point-shapes](https://lets-plot.org/kotlin/aesthetics.html#point-shapes). |
| 67 | + * @param size Size of the point. |
| 68 | + * @param stroke Width of the shape border. Applied only to the shapes having border. |
| 69 | + * @param angle Rotation angle of the shape, in degrees. |
| 70 | + * @param sizeUnit Relates the size of the point to the length of the unit step along one of the axes. |
| 71 | + * Possible values: "x", "y". If not specified, no fitting is performed. |
| 72 | + * @param colorBy default = "color" ("fill", "color", "paint_a", "paint_b", "paint_c"). |
| 73 | + * Defines the color aesthetic for the geometry. |
| 74 | + * @param fillBy default = "fill" ("fill", "color", "paint_a", "paint_b", "paint_c"). |
| 75 | + * Defines the fill aesthetic for the geometry. |
| 76 | + * @param mapping Set of aesthetic mappings. |
| 77 | + * Aesthetic mappings describe the way that variables in the data are |
| 78 | + * mapped to plot "aesthetics". |
| 79 | + */ |
| 80 | +class geomBlank( |
| 81 | + data: Map<*, *>? = null, |
| 82 | + stat: StatOptions = Stat.identity, |
| 83 | + position: PosOptions = positionIdentity, |
| 84 | + showLegend: Boolean = true, |
| 85 | + inheritAes: Boolean? = null, |
| 86 | + manualKey: Any? = null, |
| 87 | + sampling: SamplingOptions? = null, |
| 88 | + tooltips: TooltipOptions? = null, |
| 89 | + orientation: String? = null, |
| 90 | + override val map: SpatialDataset? = null, |
| 91 | + override val mapJoin: Pair<Any, Any>? = null, |
| 92 | + override val useCRS: String? = null, |
| 93 | + override val x: Number? = null, |
| 94 | + override val y: Number? = null, |
| 95 | + override val alpha: Number? = null, |
| 96 | + override val color: Any? = null, |
| 97 | + override val fill: Any? = null, |
| 98 | + override val shape: Any? = null, |
| 99 | + override val size: Number? = null, |
| 100 | + override val stroke: Number? = null, |
| 101 | + override val angle: Number? = null, |
| 102 | + override val sizeUnit: String? = null, |
| 103 | + override val colorBy: String? = null, |
| 104 | + override val fillBy: String? = null, |
| 105 | + mapping: PointMapping.() -> Unit = {} |
| 106 | + |
| 107 | +) : PointAesthetics, |
| 108 | + WithSizeUnitOption, |
| 109 | + WithSpatialParameters, |
| 110 | + WithColorOption, |
| 111 | + WithFillOption, |
| 112 | + Layer( |
| 113 | + mapping = PointMapping().apply(mapping).seal(), |
| 114 | + data = data, |
| 115 | + geom = blank, |
| 116 | + stat = stat, |
| 117 | + position = position, |
| 118 | + showLegend = showLegend, |
| 119 | + inheritAes = inheritAes ?: false, |
| 120 | + manualKey = manualKey, |
| 121 | + sampling = sampling, |
| 122 | + tooltips = tooltips, |
| 123 | + orientation = orientation |
| 124 | + ) { |
| 125 | + override fun seal() = super<PointAesthetics>.seal() + |
| 126 | + super<WithSizeUnitOption>.seal() + |
| 127 | + super<WithColorOption>.seal() + |
| 128 | + super<WithFillOption>.seal() |
| 129 | +} |
| 130 | + |
| 131 | + |
0 commit comments