All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.wings.plaf.css.PageScrollerCG Maven / Gradle / Ivy
/*
* Copyright (c) 2005 Your Corporation. All Rights Reserved.
*/
package org.wings.plaf.css;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wings.*;
import org.wings.io.Device;
import java.io.IOException;
/**
* CG for a pagescroller.
*
* @author holger
*/
public final class PageScrollerCG extends AbstractComponentCG implements org.wings.plaf.PageScrollerCG {
private static final long serialVersionUID = 1L;
private final static Logger log = LoggerFactory.getLogger(PageScrollerCG.class);
public static final int FORWARD = 0;
public static final int BACKWARD = 1;
public static final int FORWARD_BLOCK = 2;
public static final int BACKWARD_BLOCK = 3;
public static final int FIRST = 4;
public static final int LAST = 5;
private final static SIcon[][][] DEFAULT_ICONS = new SIcon[2][6][2];
static {
String[] postfixes = new String[6];
String[] prefixes = new String[6];
for (int orientation = 0; orientation < 2; orientation++) {
prefixes[BACKWARD] = "";
prefixes[FORWARD] = "";
prefixes[FIRST] = "Margin";
prefixes[LAST] = "Margin";
prefixes[FORWARD_BLOCK] = "Block";
prefixes[BACKWARD_BLOCK] = "Block";
if (orientation == SConstants.VERTICAL) {
postfixes[BACKWARD] = "Up";
postfixes[FORWARD] = "Down";
postfixes[FIRST] = "Up";
postfixes[LAST] = "Down";
postfixes[BACKWARD_BLOCK] = "Up";
postfixes[FORWARD_BLOCK] = "Down";
} else {
postfixes[BACKWARD] = "Left";
postfixes[FORWARD] = "Right";
postfixes[FIRST] = "Left";
postfixes[LAST] = "Right";
postfixes[BACKWARD_BLOCK] = "Left";
postfixes[FORWARD_BLOCK] = "Right";
}
for (int direction = 0; direction < postfixes.length; direction++) {
DEFAULT_ICONS[orientation][direction][0] =
new SResourceIcon("org/wings/icons/"
+ prefixes[direction]
+ "Scroll"
+ postfixes[direction] + ".gif");
DEFAULT_ICONS[orientation][direction][1] =
new SResourceIcon("org/wings/icons/Disabled"
+ prefixes[direction]
+ "Scroll"
+ postfixes[direction] + ".gif");
}
}
}
@Override
public void writeInternal(Device d, SComponent c)
throws IOException {
log.debug("write = " + c);
SPageScroller sb = (SPageScroller) c;
String style = sb.getStyle();
if (sb.getLayoutMode() == SConstants.VERTICAL) {
sb.setStyle(style + " SPageScroller_vertical");
writeVerticalPageScroller(d, sb);
}
else {
sb.setStyle(style + " SPageScroller_horizontal");
writeHorizontalPageScroller(d, sb);
}
sb.setStyle(style);
}
private static void writeVerticalPageScroller(Device d, SPageScroller sb) throws IOException {
int value = sb.getValue();
int extent = sb.getExtent();
int minimum = sb.getMinimum();
int maximum = sb.getMaximum();
d.print("")
.print(" ")
.print(" ")
.print("")
.print("");
int firstDirectPage = sb.getCurrentPage() - (sb.getDirectPages() - 1) / 2;
firstDirectPage = Math.min(firstDirectPage, sb.getPageCount() - sb.getDirectPages());
firstDirectPage = Math.max(firstDirectPage, 0);
for (int i = 0; i < Math.min(sb.getDirectPages(), sb.getPageCount() - firstDirectPage); i++) {
int page = firstDirectPage + i;
d.print("");
d.print(Integer.toString(page + 1));
d.print(" ");
}
d.print("
")
.print(" ")
.print("")
.print(" ")
.print(" ")
.print("
");
}
private static void verticalArea(Device d, String s, int v) throws IOException {
d.print(" ");
}
private static void writeHorizontalPageScroller(Device d, SPageScroller sb) throws IOException {
int value = sb.getValue();
int extent = sb.getExtent();
int minimum = sb.getMinimum();
int maximum = sb.getMaximum();
d.print("")
.print(" ")
.print("");
int firstDirectPage = sb.getCurrentPage() - (sb.getDirectPages() - 1) / 2;
firstDirectPage = Math.min(firstDirectPage, sb.getPageCount() - sb.getDirectPages());
firstDirectPage = Math.max(firstDirectPage, 0);
for (int i = 0; i < Math.min(sb.getDirectPages(), sb.getPageCount() - firstDirectPage); i++) {
int page = firstDirectPage + i;
d.print("");
d.print(Integer.toString(page + 1));
d.print(" ");
}
d.print("
")
.print(" ")
.print("
");
}
private static void writeIcon(Device device, SIcon icon) throws IOException {
device.print(" ");
}
}