slight refactoring of orientation handling
This commit is contained in:
parent
03f58b7b5e
commit
b5ab98668a
3 changed files with 18 additions and 25 deletions
|
|
@ -30,25 +30,16 @@ public class Dimension {
|
|||
|
||||
public Dimension scaled(int max) {
|
||||
|
||||
int sw, sh;
|
||||
if (w > h) {
|
||||
if (w > max) {
|
||||
sw = max;
|
||||
sh = (max * h + max / 2) / w;
|
||||
} else {
|
||||
sw = w;
|
||||
sh = h;
|
||||
return w > h ? scaleWidth(max) : scaleHeight(max);
|
||||
}
|
||||
} else {
|
||||
if (h > max) {
|
||||
sw = (max * w + max / 2) / h;
|
||||
sh = max;
|
||||
} else {
|
||||
sw = w;
|
||||
sh = h;
|
||||
|
||||
|
||||
public Dimension scaleWidth(int maxWidth) {
|
||||
return new Dimension(maxWidth, (maxWidth * h + maxWidth / 2) / w);
|
||||
}
|
||||
}
|
||||
return new Dimension(sw, sh);
|
||||
|
||||
public Dimension scaleHeight(int maxHeight) {
|
||||
return new Dimension((maxHeight * w + maxHeight / 2) / h, maxHeight);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class Entry {
|
|||
* @return Returns the size.
|
||||
*/
|
||||
public Dimension getSize() {
|
||||
return size;
|
||||
return getOrientation() == 6 ? size.flip() : size;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@
|
|||
text-decoration: underline;
|
||||
color: #6a6a6a;
|
||||
}
|
||||
div {
|
||||
float: left;
|
||||
}
|
||||
img {
|
||||
padding: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
|
@ -32,12 +38,8 @@
|
|||
<hr/>
|
||||
#set($thmb = 150)
|
||||
#foreach($entry in $entries)
|
||||
#if($entry.orientation == 6)
|
||||
#set($dim = $entry.size.scaled($thmb).flip())
|
||||
#else
|
||||
#set($dim = $entry.size.scaled($thmb))
|
||||
#end
|
||||
<div class="home_entry_table">
|
||||
<div class="home_entry_table" height="200">
|
||||
<span class="name">$entry.name</span><br/>
|
||||
<a href="$entry.name"><img src="$entry.name?size=$thmb" border="0" width="$dim.width" height="$dim.height"/></a><br/>
|
||||
<span class="caption">$!entry.caption</span>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue