MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / paint

Method paint

CodenameOne/src/com/codename1/ui/List.java:1226–1404  ·  view source on GitHub ↗
(Graphics g)

Source from the content-addressed store, hash-verified

1224
1225 /// {@inheritDoc}
1226 @Override
1227 public void paint(Graphics g) {
1228 getUIManager().getLookAndFeel().drawList(g, this);
1229
1230 Style style = getStyle();
1231 int width = getWidth() - style.getHorizontalPadding() - getSideGap();
1232 if (isScrollableX()) {
1233 width = Math.max(width, getScrollDimension().getWidth() - style.getHorizontalPadding() - getSideGap());
1234 }
1235 int numOfcomponents = model.getSize();
1236 if (numOfcomponents == 0) {
1237 paintHint(g);
1238 return;
1239 }
1240 int xTranslate = getX();
1241 int yTranslate = getY();
1242 g.translate(xTranslate, yTranslate);
1243 Rectangle pos = new Rectangle();
1244 Dimension rendererSize = getElementSize(false, true);
1245
1246 if (fixedSelection > FIXED_NONE_BOUNDRY) {
1247 if (animationPosition != 0 || isDragActivated()) {
1248 if (orientation != HORIZONTAL) {
1249 yTranslate += (animationPosition + fixedDraggedAnimationPosition);
1250 g.translate(0, animationPosition + fixedDraggedAnimationPosition);
1251 } else {
1252 xTranslate += (animationPosition + fixedDraggedAnimationPosition);
1253 g.translate(animationPosition + fixedDraggedAnimationPosition, 0);
1254 }
1255 }
1256 }
1257 int clipX = g.getClipX();
1258 int clipY = g.getClipY();
1259 int clipWidth = g.getClipWidth();
1260 int clipHeight = g.getClipHeight();
1261
1262 // this flag is for preformance improvements
1263 // if we figured out that the list items are not visible anymore
1264 // we should break from the List loop
1265 boolean shouldBreak = false;
1266
1267 // improve performance for browsing the end of a very large list
1268 int startingPoint = 0;
1269 if (fixedSelection < FIXED_NONE_BOUNDRY) {
1270 int startX = clipX + getAbsoluteX();
1271 if (isRTL()) {
1272 //In RTL the start of the list is not in the left side of the viewport, but rather the right side
1273 startX += getWidth();
1274 }
1275 startingPoint = Math.max(0, pointerSelect(startX, clipY + getAbsoluteY()) - 1);
1276 }
1277
1278 int startOffset = 0;
1279 int endOffset = numOfcomponents;
1280
1281 if (mutableRendererBackgrounds) {
1282 for (int i = startingPoint; i < numOfcomponents; i++) {
1283 // skip on the selected

Callers

nothing calls this directly

Calls 15

getHorizontalPaddingMethod · 0.95
getSideGapMethod · 0.95
isScrollableXMethod · 0.95
maxMethod · 0.95
getElementSizeMethod · 0.95
pointerSelectMethod · 0.95
getCurrentSelectedMethod · 0.95
intersectsMethod · 0.95
getSizeMethod · 0.95
getModelMethod · 0.95

Tested by

no test coverage detected