guy
3 years ago
13 changed files with 266 additions and 93 deletions
@ -0,0 +1,43 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element.layout.impl; |
||||
|
||||
import com.tptj.tool.hg.fineui.swing.element.Element; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.MAX_SIZE; |
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.NOT_EXIST; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021/11/1 |
||||
**/ |
||||
public class CenterLayout extends BoxLayout { |
||||
protected Element element; |
||||
|
||||
public CenterLayout(Element target, int axis) { |
||||
super(target.getComponent(), axis); |
||||
element = target; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
Dimension dim = super.preferredLayoutSize(parent); |
||||
int w = element.getRectStyleAttr("width", MAX_SIZE, NOT_EXIST); |
||||
int h = element.getRectStyleAttr("height", MAX_SIZE, NOT_EXIST); |
||||
Dimension realDim = new Dimension(w, h); |
||||
if (w == MAX_SIZE || w == NOT_EXIST) { |
||||
realDim.width = dim.width; |
||||
} |
||||
if (h == MAX_SIZE || h == NOT_EXIST) { |
||||
realDim.height = dim.height; |
||||
} |
||||
return realDim; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
super.layoutContainer(parent); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element.layout.impl; |
||||
|
||||
import com.tptj.tool.hg.fineui.swing.element.Element; |
||||
import com.tptj.tool.hg.fineui.swing.element.VerticalFlowLayout; |
||||
|
||||
import java.awt.*; |
||||
|
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.MAX_SIZE; |
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.NOT_EXIST; |
||||
|
||||
public class HorizontalLayout extends FlowLayout { |
||||
private Element element; |
||||
|
||||
public HorizontalLayout(Element target, int align, int hgap, int vgap) { |
||||
super(align, hgap, vgap); |
||||
element = target; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
Dimension dim = super.preferredLayoutSize(parent); |
||||
int w = element.getRectStyleAttr("width", MAX_SIZE, NOT_EXIST); |
||||
int h = element.getRectStyleAttr("height", MAX_SIZE, NOT_EXIST); |
||||
Dimension realDim = new Dimension(w, h); |
||||
if (w == MAX_SIZE || w == NOT_EXIST) { |
||||
realDim.width = dim.width; |
||||
} |
||||
if (h == MAX_SIZE || h == NOT_EXIST) { |
||||
realDim.height = dim.height; |
||||
} |
||||
if (element.hasScrollbar()) { |
||||
element.getWrapper().setPreferredSize(realDim); |
||||
return dim; |
||||
} |
||||
return realDim; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
super.layoutContainer(parent); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.tptj.tool.hg.fineui.swing.element.layout.impl; |
||||
|
||||
import com.tptj.tool.hg.fineui.swing.element.Element; |
||||
import com.tptj.tool.hg.fineui.swing.element.VerticalFlowLayout; |
||||
|
||||
import java.awt.*; |
||||
|
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.MAX_SIZE; |
||||
import static com.tptj.tool.hg.fineui.swing.element.layout.impl.BaseFineUILayout.NOT_EXIST; |
||||
|
||||
public class VerticalLayout extends VerticalFlowLayout { |
||||
private Element element; |
||||
|
||||
public VerticalLayout(Element target, int align, int hgap, int vgap, boolean hfill) { |
||||
super(align, hgap, vgap, hfill); |
||||
element = target; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
Dimension dim = super.preferredLayoutSize(parent); |
||||
int w = element.getRectStyleAttr("width", MAX_SIZE, NOT_EXIST); |
||||
int h = element.getRectStyleAttr("height", MAX_SIZE, NOT_EXIST); |
||||
Dimension realDim = new Dimension(w, h); |
||||
if (w == MAX_SIZE || w == NOT_EXIST) { |
||||
realDim.width = dim.width; |
||||
} |
||||
if (h == MAX_SIZE || h == NOT_EXIST) { |
||||
realDim.height = dim.height; |
||||
} |
||||
if (element.hasScrollbar()) { |
||||
element.getWrapper().setPreferredSize(realDim); |
||||
return dim; |
||||
} |
||||
return realDim; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
super.layoutContainer(parent); |
||||
} |
||||
} |
Loading…
Reference in new issue