BrightSide Workbench Full Report + Source Code
Markers.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.marker.construct;
20 
21 import org.turro.elephant.context.IConstructor;
22 import org.turro.marker.ElephantMarker;
23 
28 public class Markers {
29 
30  public Markers cssClass(String cssClass) {
31  this.cssClass = cssClass;
32  return this;
33  }
34 
35  public Markers cssStyle(String cssStyle) {
36  this.cssStyle = cssStyle;
37  return this;
38  }
39 
40  public Markers start() {
41  this.start = true;
42  return this;
43  }
44 
45  public Markers end() {
46  this.end = true;
47  return this;
48  }
49 
50  public Markers caption(String caption) {
51  this.caption = caption;
52  return this;
53  }
54 
55  public Markers image(String image) {
56  this.image = image;
57  return this;
58  }
59 
60  public Markers url(String url) {
61  this.url = url;
62  return this;
63  }
64 
65  public Markers level(int level) {
66  this.level = level;
67  return this;
68  }
69 
70  public void render(IConstructor constructor) {
71  ElephantMarker marker = new ElephantMarker(constructor);
72  marker.put("class", cssClass);
73  marker.put("style", cssStyle);
74  marker.put("start", start);
75  marker.put("end", end);
76  marker.put("caption", caption);
77  marker.put("image", image);
78  marker.put("url", url);
79  marker.put("level", level);
80  marker.process("web/utils", type.toString().toLowerCase());
81  }
82 
83  /* Properties */
84 
85  private String cssClass, cssStyle, caption, image, url;
86  private boolean start, end;
87  private int level;
88 
89  /* Types */
90 
91  private enum MarkersType {
92  SEGMENT, HEADER, DIVIDER, LINK, CARD, CARDS;
93  }
94 
95  /* Factory */
96 
97  public static Markers segment() {
98  return new Markers(MarkersType.SEGMENT);
99  }
100 
101  public static Markers header() {
102  return new Markers(MarkersType.HEADER);
103  }
104 
105  public static Markers divider() {
106  return new Markers(MarkersType.DIVIDER);
107  }
108 
109  public static Markers link() {
110  return new Markers(MarkersType.LINK);
111  }
112 
113  public static Markers card() {
114  return new Markers(MarkersType.CARD);
115  }
116 
117  public static Markers cards() {
118  return new Markers(MarkersType.CARDS);
119  }
120 
121  private final MarkersType type;
122 
123  private Markers(MarkersType type) {
124  this.type = type;
125  }
126 
127 }
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
Markers cssClass(String cssClass)
Definition: Markers.java:30
void render(IConstructor constructor)
Definition: Markers.java:70
Markers caption(String caption)
Definition: Markers.java:50
Markers image(String image)
Definition: Markers.java:55
Markers cssStyle(String cssStyle)
Definition: Markers.java:35