Dimension (final Dimension overridenSize, final Dimension ownSize) { final int overridenWidth = overridenSize.width >= 0 ? overridenSize.width : ownSize.width; final int overridenHeight = overridenSize.height >= 0 ? overridenSize.height : ownSize.height; return new Dimension(overridenWidth, overridenHeight); }