1 /*
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 } else if (fitWidth <= 0.0) {
136 newW = w;
137 }
138 if (newH < 1f) {
139 newH = 1f;
140 }
141 if (newW < 1f) {
142 newW = 1f;
143 }
144 dimension.setMaxX(dimension.getMinX() + newW);
145 dimension.setMaxY(dimension.getMinY() + newH);
146 geometryChanged();
147 }
148
149 @Override
150 protected void renderContent(Graphics g) {
151 if (null == handler || null == player) {
152 return; // not ready yet...
153 }
154
155 VideoDataBuffer frame = player.impl_getLatestFrame();
156 if (null == frame) {
157 return;
158 }
159
160 Texture texture = handler.getTexture(g, frame);
161 if (texture != null) {
162 float iw = viewport.getWidth();
163 float ih = viewport.getHeight();
164 boolean dimensionsSet = !dimension.isEmpty();
165 boolean doScale = dimensionsSet &&
166 (iw != dimension.getWidth() || ih != dimension.getHeight());
167
168 g.translate(dimension.getMinX(), dimension.getMinY());
169
170 if (doScale && iw != 0 && ih != 0) {
171 float scaleW = dimension.getWidth() / iw;
172 float scaleH = dimension.getHeight() / ih;
173 g.scale(scaleW, scaleH);
174 }
175
|
1 /*
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
135 } else if (fitWidth <= 0.0) {
136 newW = w;
137 }
138 if (newH < 1f) {
139 newH = 1f;
140 }
141 if (newW < 1f) {
142 newW = 1f;
143 }
144 dimension.setMaxX(dimension.getMinX() + newW);
145 dimension.setMaxY(dimension.getMinY() + newH);
146 geometryChanged();
147 }
148
149 @Override
150 protected void renderContent(Graphics g) {
151 if (null == handler || null == player) {
152 return; // not ready yet...
153 }
154
155 VideoDataBuffer frame = player.getLatestFrame();
156 if (null == frame) {
157 return;
158 }
159
160 Texture texture = handler.getTexture(g, frame);
161 if (texture != null) {
162 float iw = viewport.getWidth();
163 float ih = viewport.getHeight();
164 boolean dimensionsSet = !dimension.isEmpty();
165 boolean doScale = dimensionsSet &&
166 (iw != dimension.getWidth() || ih != dimension.getHeight());
167
168 g.translate(dimension.getMinX(), dimension.getMinY());
169
170 if (doScale && iw != 0 && ih != 0) {
171 float scaleW = dimension.getWidth() / iw;
172 float scaleH = dimension.getHeight() / ih;
173 g.scale(scaleW, scaleH);
174 }
175
|